'column_name' argument of DeferredForeignKey field is ignored
See original GitHub issueclass Task(Model):
[...]
CreateUser = DeferredForeignKey('User', column_name='createuser', null=True, field='ID', index=False)
UpdateUser = DeferredForeignKey('User', column_name='updateuser', null=True, field='ID', index=False)
>>> Task.select().first()
2019-03-14 12:41:03,109 DEBUG [peewee.py:2823] ('SELECT "t1"."id", "t1"."updatedt", "t1"."createdt", "t1"."state", "t1"."CreateUser", "t1"."UpdateUser", "t1"."name", "t1"."type", "t1"."start_time", "t1"."finish_time", "t1"."deadline", "t1"."result", "t1"."scenario", "t1"."wait_time", "t1"."cases_id", "t1"."locked_by", "t1"."description", "t1"."comments", "t1"."responsible_role", "t1"."previous_tasks" FROM "tasks" AS "t1" LIMIT %s', [1])
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/peewee.py", line 2835, in execute_sql
cursor.execute(sql, params or ())
File "/usr/local/lib/python3.6/site-packages/psycopg2/extras.py", line 141, in execute
return super(DictCursor, self).execute(query, vars)
psycopg2.ProgrammingError: column t1.CreateUser does not exist
LINE 1: ..., "t1"."updatedt", "t1"."createdt", "t1"."state", "t1"."Crea...
^
HINT: Perhaps you meant to reference the column "t1.createuser".
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/site-packages/peewee.py", line 1698, in inner
return method(self, database, *args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/peewee.py", line 1958, in first
return self.peek(database, n=n)
File "/usr/local/lib/python3.6/site-packages/peewee.py", line 1698, in inner
return method(self, database, *args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/peewee.py", line 1949, in peek
rows = self.execute(database)[:n]
File "/usr/local/lib/python3.6/site-packages/peewee.py", line 1698, in inner
return method(self, database, *args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/peewee.py", line 1769, in execute
return self._execute(database)
File "/usr/local/lib/python3.6/site-packages/peewee.py", line 1943, in _execute
cursor = database.execute(self)
File "/usr/local/lib/python3.6/site-packages/playhouse/postgres_ext.py", line 464, in execute
cursor = self.execute_sql(sql, params, commit=commit)
File "/usr/local/lib/python3.6/site-packages/peewee.py", line 2842, in execute_sql
self.commit()
File "/usr/local/lib/python3.6/site-packages/peewee.py", line 2627, in __exit__
reraise(new_type, new_type(*exc_args), traceback)
File "/usr/local/lib/python3.6/site-packages/peewee.py", line 178, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.6/site-packages/peewee.py", line 2835, in execute_sql
cursor.execute(sql, params or ())
File "/usr/local/lib/python3.6/site-packages/psycopg2/extras.py", line 141, in execute
return super(DictCursor, self).execute(query, vars)
peewee.ProgrammingError: column t1.CreateUser does not exist
LINE 1: ..., "t1"."updatedt", "t1"."createdt", "t1"."state", "t1"."Crea...
^
HINT: Perhaps you meant to reference the column "t1.createuser".
May be related to #1812
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
API Documentation — peewee 3.15.4 documentation
Represents a table in the database (or a table-like object such as a view). Parameters: name (str) – Database table name; columns (tuple)...
Read more >peewee — pyknotid 0.5.4 documentation - Read the Docs
REGEXP}) #: Mapping of field type to the data-type supported by the database. ... return ctx.sql(EnclosedNodeList([ (argument if isinstance(argument, ...
Read more >Kodo JDBC Subsystem Messages
Dynamic: "{0}" marks its columns as having a deferred foreign key, but the database ... Dynamic: No null-indicator column name was given for...
Read more >Fields - 《Peewee 3.13.1 Document》 - 书栈网 · BookStack
Parameters :value – arbitrary data from app or backendReturn type:python data type. class IntegerField; Field class for storing integers.
Read more >peewee Documentation [image] - manpages.ubuntu!
These are not standard Peewee Database parameters, so they will be passed ... column_name = None -- explicitly specify the column name in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@coleifer thanks for your time. I can reproduce this issue in my notebook but it’s messy now, will provide updated tests after some digging.
@NicolasCaous first, you wrong, database is initialized properly. Second, you’re pretty rude, man. I have provided just enough data to get maintainer’s answer that’s not an expected behaviour in some way.
Honestly, I kinda feel like attempting to query with an unresolved deferred foreign-key should be an error. But for now, I’ve just decided to carry forward the column name, so that it works as you’d expect.