Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG | psycopg2.errors.UndefinedColumn: CamelCase column does not exist #62

Open
v1a0 opened this issue Apr 2, 2022 · 0 comments
Open
Labels
bug Something isn't working or doesn't seems to work right

Comments

@v1a0
Copy link
Owner

v1a0 commented Apr 2, 2022

Code

db = PostgreSQLx(
            engine=psycopg2,
            dbname='test_sqllex',
            user='test_sqllex',
            password='test_sqllex'
)

db['employee'].select('id, firstName')

db['employee'].select('id', 'firstName')
Error
Traceback (most recent call last):
  File "some_postgresqlx.py", line 874, in test_select
    expected, self.db['employee'].select(['id', 'firstName'])
  File "sqllex\sqllex\core\entities\abc\sql_database.py", line 249, in select
    return self.db.select(
  File "sqllex\sqllex\core\entities\abc\sql_database.py", line 1553, in select
    return self.execute(script=script, values=values)
  File "sqllex\sqllex\core\entities\abc\sql_database.py", line 1018, in execute
    return self._executor(script=script, values=values, spec=1)
  File "sqllex\sqllex\core\entities\postgresqlx\postgresqlx.py", line 273, in _executor
    return middleware.execute(script=script, values=values, connection=self.connection)
  File "sqllex\sqllex\core\entities\postgresqlx\middleware.py", line 48, in execute
    return mw_executor(conn=connection, script=script, values=values)
  File "sqllex\sqllex\core\entities\postgresqlx\middleware.py", line 36, in mw_executor
    raise error
  File "sqllex\sqllex\core\entities\postgresqlx\middleware.py", line 19, in mw_executor
    cur.execute(script)
psycopg2.errors.UndefinedColumn: column "firstname" does not exist
LINE 1: SELECT id, firstName FROM "employee"
                   ^
HINT:  Perhaps you meant to reference the column "employee.firstName".

Temporary fix

use " or full column name employee."firstName"

db['employee'].select("""
id, "firstName"
""")

# OR

db['employee'].select('employee.id', 'employee."firstName"')
@v1a0 v1a0 added the bug Something isn't working or doesn't seems to work right label Apr 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working or doesn't seems to work right
Projects
None yet
Development

No branches or pull requests

1 participant