Giter Site home page Giter Site logo

Comments (3)

MisterNando avatar MisterNando commented on July 22, 2024

Tagging @millerdev , per @czue's recommendation.

from django-cte.

millerdev avatar millerdev commented on July 22, 2024

@MisterNando this is a strange error. I'm unable to tell from the given traceback how as_sql() is being called with extra arguments. Can you find out what code is calling as_sql() when the error occurs?

If you cannot do that, can you find out what the values of args and kwargs are when the error occurs? Maybe temporarily add a print statement to the method and capture the output:

class CTEUpdateQueryCompiler(SQLUpdateCompiler):

    def as_sql(self, *args, **kwargs):
        print(args, kwargs)  # <---- capture the output of this when the error occurs
        def _as_sql():
            return super(CTEUpdateQueryCompiler, self).as_sql(*args, **kwargs)
        return CTECompiler.generate_sql(self.connection, self.query, _as_sql)

from django-cte.

MisterNando avatar MisterNando commented on July 22, 2024

Thanks for responding, @millerdev ! I can no longer reproduce the conditions that resulted in the error; however, I was able to dig up a more detailed stacktrace from our log archives:

[07/Sep/2018 09:00:00]::ERROR::api.py:34::as_sql() takes exactly 1 argument (3 given)
  File "./asset_api/api/asset_checkin/api.py", line 27, in post
    handler.resend_jobs_on_agent_request()
  File "./asset_api/api/asset_checkin/utils.py", line 95, in resend_jobs_on_agent_request
    ).update(outcome_id=Globals.Outcome.Errored)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 647, in update
    rows = query.get_compiler(self.db).execute_sql(CURSOR)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 1199, in execute_sql
    cursor = super(SQLUpdateCompiler, self).execute_sql(result_type)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 871, in execute_sql
    sql, params = self.as_sql()
  File "/usr/local/lib/python2.7/dist-packages/django_cte/query.py", line 113, in as_sql
    return CTECompiler.generate_sql(self.connection, self.query, _as_sql)
  File "/usr/local/lib/python2.7/dist-packages/django_cte/query.py", line 80, in generate_sql
    base_sql, base_params = as_sql()
  File "/usr/local/lib/python2.7/dist-packages/django_cte/query.py", line 112, in _as_sql
    return super(CTEUpdateQueryCompiler, self).as_sql(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 1187, in as_sql
    where, params = self.compile(self.query.where)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 373, in compile
    sql, params = node.as_sql(self, self.connection)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/where.py", line 79, in as_sql
    sql, params = compiler.compile(child)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 373, in compile
    sql, params = node.as_sql(self, self.connection)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/lookups.py", line 381, in as_sql
    return super(In, self).as_sql(compiler, connection)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/lookups.py", line 170, in as_sql
    rhs_sql, rhs_params = self.process_rhs(compiler, connection)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/lookups.py", line 372, in process_rhs
    return super(In, self).process_rhs(compiler, connection)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/lookups.py", line 229, in process_rhs
    return super(FieldGetDbPrepValueIterableMixin, self).process_rhs(compiler, connection)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/lookups.py", line 100, in process_rhs
    sql, params = compiler.compile(value)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 373, in compile
    sql, params = node.as_sql(self, self.connection)
  File "/usr/local/lib/python2.7/dist-packages/django_cte/query.py", line 113, in as_sql
    return CTECompiler.generate_sql(self.connection, self.query, _as_sql)
  File "/usr/local/lib/python2.7/dist-packages/django_cte/query.py", line 80, in generate_sql
    base_sql, base_params = as_sql()
  File "/usr/local/lib/python2.7/dist-packages/django_cte/query.py", line 112, in _as_sql
    return super(CTEUpdateQueryCompiler, self).as_sql(*args, **kwargs)
TypeError: as_sql() takes exactly 1 argument (3 given)

It looks like the Django SQLCompiler is calling as_sql() with itself and the DB connection as arguments (line 373 in compiler.py).

Does this provide you with the information that you need to proceed with your debugging?

from django-cte.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.