url
stringlengths 53
56
| repository_url
stringclasses 1
value | labels_url
stringlengths 67
70
| comments_url
stringlengths 62
65
| events_url
stringlengths 60
63
| html_url
stringlengths 41
46
| id
int64 450k
1.69B
| node_id
stringlengths 18
32
| number
int64 1
2.72k
| title
stringlengths 1
209
| user
dict | labels
list | state
stringclasses 1
value | locked
bool 2
classes | assignee
null | assignees
sequence | milestone
null | comments
sequence | created_at
timestamp[s] | updated_at
timestamp[s] | closed_at
timestamp[s] | author_association
stringclasses 3
values | active_lock_reason
stringclasses 2
values | body
stringlengths 0
104k
⌀ | reactions
dict | timeline_url
stringlengths 62
65
| performed_via_github_app
null | state_reason
stringclasses 2
values | draft
bool 2
classes | pull_request
dict |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
https://api.github.com/repos/coleifer/peewee/issues/1818 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1818/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1818/comments | https://api.github.com/repos/coleifer/peewee/issues/1818/events | https://github.com/coleifer/peewee/issues/1818 | 393,637,118 | MDU6SXNzdWUzOTM2MzcxMTg= | 1,818 | SQLite not respecting CharField or FixedCharField max_length | {
"login": "stigok",
"id": 952936,
"node_id": "MDQ6VXNlcjk1MjkzNg==",
"avatar_url": "https://avatars.githubusercontent.com/u/952936?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/stigok",
"html_url": "https://github.com/stigok",
"followers_url": "https://api.github.com/users/stigok/followers",
"following_url": "https://api.github.com/users/stigok/following{/other_user}",
"gists_url": "https://api.github.com/users/stigok/gists{/gist_id}",
"starred_url": "https://api.github.com/users/stigok/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/stigok/subscriptions",
"organizations_url": "https://api.github.com/users/stigok/orgs",
"repos_url": "https://api.github.com/users/stigok/repos",
"events_url": "https://api.github.com/users/stigok/events{/privacy}",
"received_events_url": "https://api.github.com/users/stigok/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"> Values that exceed length are not truncated automatically.\r\n\r\nAs that says, values that exceed length **are not truncated**.\r\n\r\nI'd suggest that you should familiarize yourself with the database you're using, sqlite in this case: https://sqlite.org/datatype3.html\r\n\r\nSqlite has the following data-types:\r\n\r\n* text\r\n* blob\r\n* integer\r\n* real (float)\r\n* null\r\n\r\nCreating a `*char*` column will use the `text` data-type, but there is no validation of max-lengths or anything. You can create an explicit constraint, but the default behavior is just to treat it as text.",
"That is a great suggestion. I went ahead and made assumptions I shouldn't have made. Thank you for the tips.\r\n\r\nFor reference, taken from the [SQLite documentation about quirks](https://sqlite.org/quirks.html#flexible_typing):\r\n> [...] SQLite allows you to store a 2000-character string into a column of type VARCHAR(50). Other SQL implementions would either throw an error or truncate the string. SQLite stores the entire 2000-character string with no loss of information and without complaint. [...]"
] | 2018-12-22T02:57:25 | 2018-12-22T21:16:06 | 2018-12-22T16:50:39 | NONE | null | ```python
from peewee import *
database = SqliteDatabase(':memory:')
class User(Model):
class Meta:
database = database
username = CharField(max_length=21)
database.create_tables([User])
username = 'a' * 42
assert len(username) == 42
u = User.create(username=username)
assert u.username == username
u = User.get(username=username)
assert u.username == username
```
Nothing special happens when attempting to insert values of length > `max_length` into fields of type `CharField` or `FixedCharField`. Reading the code, I can not find any validation steps performed for respecting `max_length` either.
I was expecting an exception to be raised due to [docs stating](http://docs.peewee-orm.com/en/latest/peewee/api.html#CharField)
> Values that exceed length are not truncated automatically. | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1818/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1818/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1817 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1817/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1817/comments | https://api.github.com/repos/coleifer/peewee/issues/1817/events | https://github.com/coleifer/peewee/issues/1817 | 392,958,318 | MDU6SXNzdWUzOTI5NTgzMTg= | 1,817 | Do I need additional steps to use ArrayField? | {
"login": "msdos",
"id": 489034,
"node_id": "MDQ6VXNlcjQ4OTAzNA==",
"avatar_url": "https://avatars.githubusercontent.com/u/489034?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/msdos",
"html_url": "https://github.com/msdos",
"followers_url": "https://api.github.com/users/msdos/followers",
"following_url": "https://api.github.com/users/msdos/following{/other_user}",
"gists_url": "https://api.github.com/users/msdos/gists{/gist_id}",
"starred_url": "https://api.github.com/users/msdos/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/msdos/subscriptions",
"organizations_url": "https://api.github.com/users/msdos/orgs",
"repos_url": "https://api.github.com/users/msdos/repos",
"events_url": "https://api.github.com/users/msdos/events{/privacy}",
"received_events_url": "https://api.github.com/users/msdos/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"See 04aa7a0 for the fix.",
"Is this planned to a 3.8.1 release? The fix was really fast, thanks.",
"I'll release this fix along with 3.8.1 at some point in the coming days/weeks.\r\n\r\nIn the meantime there are a number of workarounds. The simplest being instead of using `.get()` with keyword arguments, use expressions, e.g.: `MyModel.foo == 'bar'` is *always* preferable to `foo='bar'`."
] | 2018-12-20T09:28:47 | 2018-12-20T16:35:39 | 2018-12-20T15:34:58 | NONE | null | I'm trying to use the `ArrayField` from Postgresql but I can't use your `get` method. Here is a proof of concept of the problem I'm facing it (I adapted the sample code from an old issue here in the repository):
```python
#!/usr/bin/env python
from peewee import Model
from peewee import TextField
from playhouse.postgres_ext import ArrayField
from playhouse.postgres_ext import PostgresqlExtDatabase
from playhouse.shortcuts import model_to_dict
db = PostgresqlExtDatabase(
'peewee_test',
user='postgres',
password='postgres',
host='localhost',
autorollback=True
)
class BaseModel(Model):
class Meta:
database = db
class BlogPost(BaseModel):
title = TextField()
tags = ArrayField(TextField)
def main():
db.create_tables([BlogPost])
BlogPost.delete().execute()
BlogPost.create(
title='awesome',
tags=['foo', 'bar', 'baz'])
BlogPost.create(
title='bad',
tags=['foo', 'bax', 'baz'])
for b in BlogPost.select().where(BlogPost.tags.contains_any('python', 'bar')): # NOQA
print(b.title)
"""SQL so far:
SELECT tablename FROM pg_catalog.pg_tables WHERE schemaname = %s ORDER BY tablename
DELETE FROM "blogpost"
INSERT INTO "blogpost" ("title", "tags") VALUES (%s, %s) RETURNING "blogpost"."id"
INSERT INTO "blogpost" ("title", "tags") VALUES (%s, %s) RETURNING "blogpost"."id"
SELECT "t1"."id", "t1"."title", "t1"."tags" FROM "blogpost" AS "t1" WHERE ("t1"."tags" && %s::TEXT[])
"""
model_dict = model_to_dict(b)
print(model_dict)
b = BlogPost.get(**model_dict)
"""SQL so far:
SELECT "t1"."id", "t1"."title", "t1"."tags" FROM "blogpost" AS "t1" WHERE ((("t1"."id" = %s) AND ("t1"."tags" = (%s, %s, %s))) AND ("t1"."title" = %s)) LIMIT %s OFFSET %s
peewee.py", line 2712, in execute_sql
cursor.execute(sql, params or ())
psycopg2.ProgrammingError: operator does not exist: text[] = record
LINE 1: ... AS "t1" WHERE ((("t1"."id" = 3) AND ("t1"."tags" = (ARRAY['...
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
"""
if __name__ == '__main__':
main()
```
I'm using Postgresql 10.6, Python 3.6.7 and peewee 3.8.0 (psycopg2 is 2.7.6.1) | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1817/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1817/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1816 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1816/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1816/comments | https://api.github.com/repos/coleifer/peewee/issues/1816/events | https://github.com/coleifer/peewee/issues/1816 | 392,595,972 | MDU6SXNzdWUzOTI1OTU5NzI= | 1,816 | Unable to create model with ManyToManyField | {
"login": "skopz356",
"id": 36794259,
"node_id": "MDQ6VXNlcjM2Nzk0MjU5",
"avatar_url": "https://avatars.githubusercontent.com/u/36794259?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/skopz356",
"html_url": "https://github.com/skopz356",
"followers_url": "https://api.github.com/users/skopz356/followers",
"following_url": "https://api.github.com/users/skopz356/following{/other_user}",
"gists_url": "https://api.github.com/users/skopz356/gists{/gist_id}",
"starred_url": "https://api.github.com/users/skopz356/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/skopz356/subscriptions",
"organizations_url": "https://api.github.com/users/skopz356/orgs",
"repos_url": "https://api.github.com/users/skopz356/repos",
"events_url": "https://api.github.com/users/skopz356/events{/privacy}",
"received_events_url": "https://api.github.com/users/skopz356/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"Read the docs: http://docs.peewee-orm.com/en/latest/peewee/relationships.html#manytomany\r\n\r\nAnd: http://docs.peewee-orm.com/en/latest/peewee/relationships.html#manytomanyfield",
"I read the docs many times, but i still did not find what am i doing bad?"
] | 2018-12-19T13:13:06 | 2018-12-19T13:50:46 | 2018-12-19T13:43:35 | NONE | null | Hi, I am using mysql version 5.7.24 and when i try to create Model with ManyToMany relations i got
error:
```
raise errorclass(errno, errval)
peewee.IntegrityError: (1048, "Column 'chat_id' cannot be null")
```
Here is my code:
```
class User(BaseModel):
name = peewee.CharField()
surname = peewee.CharField()
email = peewee.CharField()
def __str__(self):
return self.surname
lass Message(BaseModel):
text = peewee.CharField()
send_by = peewee.ForeignKeyField(User)
def __str__(self):
return self.text
class Chat(BaseModel, ManyToManyModel):
message = ManyToManyField(Message, backref="chats")
user = ManyToManyField(User, backref="users")
u = User.get(id=1)
m = Message.get(id=1)
Chat.create(message=m, user=u)
```
I have created tables chat_message_through and chat_user_through.
Thanks for help
| {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1816/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1816/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1815 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1815/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1815/comments | https://api.github.com/repos/coleifer/peewee/issues/1815/events | https://github.com/coleifer/peewee/issues/1815 | 392,387,733 | MDU6SXNzdWUzOTIzODc3MzM= | 1,815 | .on_conflict() update parameter does not adapt dicts (Postgres) | {
"login": "lohrmann",
"id": 5954956,
"node_id": "MDQ6VXNlcjU5NTQ5NTY=",
"avatar_url": "https://avatars.githubusercontent.com/u/5954956?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/lohrmann",
"html_url": "https://github.com/lohrmann",
"followers_url": "https://api.github.com/users/lohrmann/followers",
"following_url": "https://api.github.com/users/lohrmann/following{/other_user}",
"gists_url": "https://api.github.com/users/lohrmann/gists{/gist_id}",
"starred_url": "https://api.github.com/users/lohrmann/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/lohrmann/subscriptions",
"organizations_url": "https://api.github.com/users/lohrmann/orgs",
"repos_url": "https://api.github.com/users/lohrmann/repos",
"events_url": "https://api.github.com/users/lohrmann/events{/privacy}",
"received_events_url": "https://api.github.com/users/lohrmann/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"As a temporary workaround, try using the actual field objects instead of the field-names as strings, e.g.:\r\n\r\n```python\r\nrecord = {\r\n Session.someid: 'textid',\r\n Session.tstp: datetime.datetime(2018, 12, 12),\r\n Session.data: {},\r\n}\r\n```",
"Fixed by f59ee6d"
] | 2018-12-19T00:06:54 | 2018-12-19T03:34:01 | 2018-12-19T03:31:49 | NONE | null | When a record includes dictionary data for a JSONB column in postgres, the data is correctly adapted in insert or update statements, but fails to be adapted as part of the .on_conflict() clause's update parameter.
The following (simplified)
record = {'someid': 'textid', 'tstp': datetime(2018, 12, 12, 15, 30, 30), 'somecolumn': 'text', 'data': {}}
(SomeTable.insert(record)
.on_conflict('update', conflict_target=[s.someid, s.tstp], update=record))
sends the following statement
('INSERT INTO "someschema"."sometable" ("someid", "tstp", "somecolumn", "data") VALUES
(%s, %s, %s, %s)
ON CONFLICT ("someid", "tstp")
DO UPDATE SET
"someid" = %s, "tstp" = %s, "somecolumn" = %s, "data" = %s
RETURNING "session"."id"'
, ['textid',
'2018-12-12 15:30:30',
'text',
<psycopg2._json.Json object at 0x11215bd30>,
'textid',
'2018-12-12 15:30:30',
'text',
{}])
resulting in a `peewee.ProgrammingError: can't adapt type 'dict'`.
I am using peewee 3.8.0. Is this intended behaviour? ~~As a workaround I'm using a try/except clause in combination with an insert statement (the more common operation), but this of course means two queries to the database in case of conflict. Are there any more efficient workarounds, e.g. manually pre-converting the dict into a psycopg2 json object?~~
Edit: Using `from psycopg2.extras import Json`, the dict can successfully be pre-converted and the .on_conflict() clause executes successfully.
| {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1815/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1815/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1814 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1814/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1814/comments | https://api.github.com/repos/coleifer/peewee/issues/1814/events | https://github.com/coleifer/peewee/issues/1814 | 392,253,014 | MDU6SXNzdWUzOTIyNTMwMTQ= | 1,814 | Slower insert_many performance relative to sqlite3 executemany | {
"login": "rpadmanabhan",
"id": 7334318,
"node_id": "MDQ6VXNlcjczMzQzMTg=",
"avatar_url": "https://avatars.githubusercontent.com/u/7334318?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/rpadmanabhan",
"html_url": "https://github.com/rpadmanabhan",
"followers_url": "https://api.github.com/users/rpadmanabhan/followers",
"following_url": "https://api.github.com/users/rpadmanabhan/following{/other_user}",
"gists_url": "https://api.github.com/users/rpadmanabhan/gists{/gist_id}",
"starred_url": "https://api.github.com/users/rpadmanabhan/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/rpadmanabhan/subscriptions",
"organizations_url": "https://api.github.com/users/rpadmanabhan/orgs",
"repos_url": "https://api.github.com/users/rpadmanabhan/repos",
"events_url": "https://api.github.com/users/rpadmanabhan/events{/privacy}",
"received_events_url": "https://api.github.com/users/rpadmanabhan/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"Only 2x is really not as bad as I might have thought.\r\n\r\nYes, it's because peewee contains logic for converting python data-types to data-types that can be handled by the database. For example, if you're using `TimestampField` you work with `datetime` objects in Python code, but when it comes to interacting with the DB we convert this to an integer. So when you are inserting objects, peewee is efficient, but it still must make sure to apply all conversions to the application data before sending it to the db. Same applies when reading from a cursor.\r\n\r\nThe code in peewee is optimized and uses efficient algorithms, but its doing a lot for you to make life easier and there's a performance cost.\r\n\r\nAt the end of the day remember that it's python. It's slow compared to C. You want to go fast? Use C.",
"Thanks for the reply. For anyone else who stumbles on this. I was able to get similar performance as sqlite's executemany using using peewee's execute_sql like this. Not ideal, but is worth it for me because of large inserts i need to do and since this table has pretty simple data types. \r\n\r\nI like to use peewee for the other nice features like datetime you mentioned.\r\n\r\n``` python\r\ninsert_query = ''' INSERT OR IGNORE INTO foo_table (seq, params_in, results_out) VALUES (?, ?, ?) '''\r\nwith db.atomic():\r\n for row in to_insert:\r\n db.execute_sql(insert_query, row)\r\n```\r\n\r\n",
"For select queries, when you are iterating over lots of rows, here are some docs that may be helpful:\r\n\r\nhttp://docs.peewee-orm.com/en/latest/peewee/querying.html#iterating-over-large-result-sets",
"There's also [sweepea](https://github.com/coleifer/sweepea), a sqlite query-builder I wrote using Cython that may be faster."
] | 2018-12-18T17:10:08 | 2018-12-18T21:00:29 | 2018-12-18T17:18:24 | NONE | null | Thank you for developing peewee, it is a great lightweight ORM !
I am inserting batches in peewee like this :
```python
import peewee
db = peewee.SqliteDatabase('test_db.sqlite3',pragmas={'synchronous': 0,' 'journal_mode':'wal'})
with db.atomic(): # 10000 rows in this transaction
for batch in peewee.chunked(to_insert,249):
FooTable.insert_many(batch, fields=[Bar.seq, Bar.params_in, Bar.results_out]).on_conflict_ignore(True).execute()
```
I am able to insert twice as fast using sqlite3's executemany function. I am using the same PRAGMA options in both. The table has primary key on a string column seq.
``` python
import sqlite3
insert_query = ''' INSERT OR IGNORE INTO foo_table (seq, params_in, results_out) VALUES (?, ?, ?) '''
conn = sqlite3.connect('test_db.sqlite3')
conn.execute('PRAGMA synchronous = OFF')
conn.execute('PRAGMA journal_mode = wal')
conn.commit()
conn.executemany(insert_query, to_insert) # 10000 rows
conn.commit()
```
While the inserts are reasonably fast using peewee (~ 30000 inserts a sec) , I wanted to know why it is ~ 2x slower than using sqlite3, or is this much slowdown expected because of the abstraction layer provided by the ORM ?
| {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1814/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1814/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1813 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1813/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1813/comments | https://api.github.com/repos/coleifer/peewee/issues/1813/events | https://github.com/coleifer/peewee/pull/1813 | 390,864,550 | MDExOlB1bGxSZXF1ZXN0MjM4NTM1ODEx | 1,813 | setdefault added to playhouse kv, for dict like setdefault behavior | {
"login": "ascourge21",
"id": 9159496,
"node_id": "MDQ6VXNlcjkxNTk0OTY=",
"avatar_url": "https://avatars.githubusercontent.com/u/9159496?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/ascourge21",
"html_url": "https://github.com/ascourge21",
"followers_url": "https://api.github.com/users/ascourge21/followers",
"following_url": "https://api.github.com/users/ascourge21/following{/other_user}",
"gists_url": "https://api.github.com/users/ascourge21/gists{/gist_id}",
"starred_url": "https://api.github.com/users/ascourge21/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/ascourge21/subscriptions",
"organizations_url": "https://api.github.com/users/ascourge21/orgs",
"repos_url": "https://api.github.com/users/ascourge21/repos",
"events_url": "https://api.github.com/users/ascourge21/events{/privacy}",
"received_events_url": "https://api.github.com/users/ascourge21/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"Thnx."
] | 2018-12-13T21:20:12 | 2018-12-23T01:15:16 | 2018-12-14T10:33:15 | CONTRIBUTOR | null | To make KeyValue behave more like the regular python dict, a setdefault is also added.
This is a feature that we regularly use in our team when the db isn't initialized with any value, especially for settings and config items. | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1813/reactions",
"total_count": 1,
"+1": 1,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1813/timeline | null | null | false | {
"url": "https://api.github.com/repos/coleifer/peewee/pulls/1813",
"html_url": "https://github.com/coleifer/peewee/pull/1813",
"diff_url": "https://github.com/coleifer/peewee/pull/1813.diff",
"patch_url": "https://github.com/coleifer/peewee/pull/1813.patch",
"merged_at": "2018-12-14T10:33:15"
} |
https://api.github.com/repos/coleifer/peewee/issues/1812 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1812/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1812/comments | https://api.github.com/repos/coleifer/peewee/issues/1812/events | https://github.com/coleifer/peewee/issues/1812 | 390,404,721 | MDU6SXNzdWUzOTA0MDQ3MjE= | 1,812 | Broken DeferredForeignKey inheritance | {
"login": "NicolasCaous",
"id": 24411365,
"node_id": "MDQ6VXNlcjI0NDExMzY1",
"avatar_url": "https://avatars.githubusercontent.com/u/24411365?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/NicolasCaous",
"html_url": "https://github.com/NicolasCaous",
"followers_url": "https://api.github.com/users/NicolasCaous/followers",
"following_url": "https://api.github.com/users/NicolasCaous/following{/other_user}",
"gists_url": "https://api.github.com/users/NicolasCaous/gists{/gist_id}",
"starred_url": "https://api.github.com/users/NicolasCaous/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/NicolasCaous/subscriptions",
"organizations_url": "https://api.github.com/users/NicolasCaous/orgs",
"repos_url": "https://api.github.com/users/NicolasCaous/repos",
"events_url": "https://api.github.com/users/NicolasCaous/events{/privacy}",
"received_events_url": "https://api.github.com/users/NicolasCaous/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"Thanks for the report, I will look into it.",
"I would like to contribute in a solution as well, but it's hard to understand how the project is structured. Do you have any tips for where to begin?",
"The code's only a few thousand lines, definitely readable in one sitting. You can ignore everything except `peewee.py` for getting started."
] | 2018-12-12T20:54:40 | 2018-12-13T15:00:18 | 2018-12-13T14:54:31 | NONE | null | This is quite a complicated issue. I will try to do my best to give as much information as possible.
## The code
```
from peewee import *
from models.base_model import BaseModel, BaseHistory
class Company(BaseModel):
teste = TextField()
user = DeferredForeignKey('User', null=True)
class CompanyHistory(Company, BaseHistory):
pass
```
```
from peewee import *
from util.server import SERVER
import datetime
class BaseModel(Model):
id = BigAutoField()
created_at_utc = DateTimeField(default = lambda: datetime.datetime.utcnow())
created_at_local = DateTimeField(default = lambda: datetime.datetime.now())
class Meta:
database = SERVER['database']
legacy_table_names = False
class BaseHistory(Model):
updated_at_utc = DateTimeField(default = lambda: datetime.datetime.utcnow())
updated_at_local = DateTimeField(default = lambda: datetime.datetime.now())
```
## The problem
When trying to create `CompanyHistory` table inside the database, the following error message appears:
> peewee.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NOT NULL)' at line 1")
"What? SQL Syntax? I don't control that, it must be peewee." I thought. So I dig it through:
Using pdb I was able to retrieve the parsed SQL query from peewee:

raw:
```
'CREATE TABLE IF NOT EXISTS `company_history` (`id` INTEGER AUTO_INCREMENT NOT NULL PRIMARY KEY, `created_at_utc` DATETIME NOT NULL, `created_at_local` DATETIME NOT NULL, `updated_at_utc` DATETIME NOT NULL, `updated_at_local` DATETIME NOT NULL, `teste` TEXT NOT NULL, `user` NOT NULL)'
```
pretty:
```
CREATE TABLE IF NOT EXISTS `company_history` (
`id` BIGINT AUTO_INCREMENT NOT NULL PRIMARY KEY,
`created_at_utc` DATETIME NOT NULL,
`created_at_local` DATETIME NOT NULL,
`updated_at_utc` DATETIME NOT NULL,
`updated_at_local` DATETIME NOT NULL,
`teste` TEXT NOT NULL,
`user` NOT NULL
)
```
The type of the user column is missing.
## Conclusion
Field inheritance is broken for `DeferredForeignKey`
## Workaround
redefine the field:
```
from peewee import *
from models.base_model import BaseModel, BaseHistory
class Company(BaseModel):
teste = TextField()
user = DeferredForeignKey('User', null=True)
class CompanyHistory(Company, BaseHistory):
user = DeferredForeignKey('User', null=True)
pass
```
| {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1812/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1812/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1811 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1811/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1811/comments | https://api.github.com/repos/coleifer/peewee/issues/1811/events | https://github.com/coleifer/peewee/issues/1811 | 390,149,673 | MDU6SXNzdWUzOTAxNDk2NzM= | 1,811 | Update requirements.txt | {
"login": "denysthegitmenace",
"id": 10329935,
"node_id": "MDQ6VXNlcjEwMzI5OTM1",
"avatar_url": "https://avatars.githubusercontent.com/u/10329935?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/denysthegitmenace",
"html_url": "https://github.com/denysthegitmenace",
"followers_url": "https://api.github.com/users/denysthegitmenace/followers",
"following_url": "https://api.github.com/users/denysthegitmenace/following{/other_user}",
"gists_url": "https://api.github.com/users/denysthegitmenace/gists{/gist_id}",
"starred_url": "https://api.github.com/users/denysthegitmenace/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/denysthegitmenace/subscriptions",
"organizations_url": "https://api.github.com/users/denysthegitmenace/orgs",
"repos_url": "https://api.github.com/users/denysthegitmenace/repos",
"events_url": "https://api.github.com/users/denysthegitmenace/events{/privacy}",
"received_events_url": "https://api.github.com/users/denysthegitmenace/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"+ add `micawber` dependency",
"thx, updated."
] | 2018-12-12T10:02:53 | 2018-12-13T12:37:20 | 2018-12-13T12:37:15 | NONE | null | Hi! Thank you so much for this useful repo. `Beautifulsoup` in `examples/blog/requirements.txt` should be udpated to `beautifulsoup4`. | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1811/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1811/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1810 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1810/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1810/comments | https://api.github.com/repos/coleifer/peewee/issues/1810/events | https://github.com/coleifer/peewee/issues/1810 | 390,144,544 | MDU6SXNzdWUzOTAxNDQ1NDQ= | 1,810 | Different result with 'or' - '|' | {
"login": "BreX900",
"id": 44398785,
"node_id": "MDQ6VXNlcjQ0Mzk4Nzg1",
"avatar_url": "https://avatars.githubusercontent.com/u/44398785?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/BreX900",
"html_url": "https://github.com/BreX900",
"followers_url": "https://api.github.com/users/BreX900/followers",
"following_url": "https://api.github.com/users/BreX900/following{/other_user}",
"gists_url": "https://api.github.com/users/BreX900/gists{/gist_id}",
"starred_url": "https://api.github.com/users/BreX900/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/BreX900/subscriptions",
"organizations_url": "https://api.github.com/users/BreX900/orgs",
"repos_url": "https://api.github.com/users/BreX900/repos",
"events_url": "https://api.github.com/users/BreX900/events{/privacy}",
"received_events_url": "https://api.github.com/users/BreX900/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"Read the docs:\r\n\r\nhttp://docs.peewee-orm.com/en/latest/peewee/query_operators.html\r\n"
] | 2018-12-12T09:50:20 | 2018-12-12T13:02:45 | 2018-12-12T13:02:45 | NONE | null | I'm not very good at English. I will show the error with two examples. The same examples should show the same result but it is not...
`#first example
f = (Product.asin_product=="NameOne")
f = f | (Product.asin_product=="NameTwo")
Product.select().where(f).execute()
#peewee - DEBUG - ('SELECT "t1"."asin_product" FROM "product" AS "t1" WHERE (("t1"."asin_product" = %s) OR ("t1"."asin_product" = %s))', ['NameOne', 'NameTwo'])
#Second example
s = (Product.asin_product == "NameOne")
s = s or (Product.asin_product == "NameTwo")
Product.select().where(s).execute()
#2018-12-12 10:46:28,754 - peewee - DEBUG - ('SELECT "t1"."asin_product" FROM "product" AS "t1" WHERE ("t1"."asin_product" = %s)', ['NameOne'])`
They should return the same query as a result, but it is not | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1810/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1810/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1809 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1809/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1809/comments | https://api.github.com/repos/coleifer/peewee/issues/1809/events | https://github.com/coleifer/peewee/issues/1809 | 389,533,616 | MDU6SXNzdWUzODk1MzM2MTY= | 1,809 | Common Table Expressions and .count() | {
"login": "christopherhesse",
"id": 440336,
"node_id": "MDQ6VXNlcjQ0MDMzNg==",
"avatar_url": "https://avatars.githubusercontent.com/u/440336?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/christopherhesse",
"html_url": "https://github.com/christopherhesse",
"followers_url": "https://api.github.com/users/christopherhesse/followers",
"following_url": "https://api.github.com/users/christopherhesse/following{/other_user}",
"gists_url": "https://api.github.com/users/christopherhesse/gists{/gist_id}",
"starred_url": "https://api.github.com/users/christopherhesse/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/christopherhesse/subscriptions",
"organizations_url": "https://api.github.com/users/christopherhesse/orgs",
"repos_url": "https://api.github.com/users/christopherhesse/repos",
"events_url": "https://api.github.com/users/christopherhesse/events{/privacy}",
"received_events_url": "https://api.github.com/users/christopherhesse/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"Ahh, yeah, `count()` appears not to be taking into consideration the fact that the query has a CTE. This is a usage I hadn't considered.\r\n\r\nI'd suggest just modifying your own SQL in the meantime as a workaround, e.g., to get the count, just write a query that looks like `.select(fn.COUNT(...))`.",
"Thanks for the suggestion, but I first noticed this when using `from playhouse.flask_utils import PaginatedQuery` which seems to use `.count()` internally. Should I just change the source of that file to use this `.select(fn.COUNT(...))` method?",
"Ehh, or you could subclass `PaginatedQuery` and override the `get_page_count()` method? ",
"I ended up re-writing the query to not use CTEs. Do you have any interest in fixing CTEs with `count()`?",
"I'm leaving the issue open for now as I believe there's a bug here. I just haven't figured out yet how to address it.",
"A similar issue is reported by @iksteen in #1838.\r\n\r\nSince these are closely related, I'm including the issue description here:\r\n\r\n----------------------------------------------------------------\r\n\r\nConsider the following example (note that this is obviously a silly example, but just enough to show the problem):\r\n```\r\nfrom peewee import *\r\ndb = PostgresqlDatabase('scoreboard')\r\n\r\nclass Base(Model):\r\n class Meta:\r\n database = db\r\n\r\nclass Challenge(Base):\r\n pass\r\n\r\nclass Attachment(Base):\r\n challenge = ForeignKeyField(Challenge, backref='attachments')\r\n\r\ncte = (\r\n Challenge\r\n .select(fn.MAX(Challenge.id).alias('max_id'))\r\n .cte('demo')\r\n)\r\n\r\nq = (\r\n Challenge\r\n .select(Challenge)\r\n .join(cte, on=(Challenge.id == cte.c.min_id))\r\n .with_cte(cte)\r\n)\r\np = Attachment.select()\r\nr = prefetch(q, p)\r\nprint(list(r))\r\n```\r\n\r\nThe generated SQL for the prefetch of Attachment will be:\r\n```\r\nSELECT \"t1\".\"id\", \"t1\".\"challenge_id\" FROM \"attachment\" AS \"t1\"\r\nWHERE (\r\n \"t1\".\"challenge_id\" IN\r\n WITH \"demo\" AS ((SELECT MAX(\"t2\".\"id\") AS \"min_id\" FROM \"challenge\" AS \"t2\"))\r\n (SELECT \"t3\".\"id\" FROM \"challenge\" AS \"t3\" INNER JOIN \"demo\" ON (\"t3\".\"id\" = \"demo\".\"min_id\"))\r\n)\r\n```\r\n\r\nWhile the CTE queries and the subquery themselves do get extra parentheses, the base query is not parenthesized leaving the `WITH` part bare and resulting in an invalid syntax.\r\n\r\nThe expected query would be:\r\n```\r\nSELECT \"t1\".\"id\", \"t1\".\"challenge_id\" FROM \"attachment\" AS \"t1\"\r\nWHERE (\r\n \"t1\".\"challenge_id\" IN (\r\n WITH \"demo\" AS (SELECT MAX(\"t2\".\"id\") AS \"min_id\" FROM \"challenge\" AS \"t2\")\r\n SELECT \"t3\".\"id\" FROM \"challenge\" AS \"t3\" INNER JOIN \"demo\" ON (\"t3\".\"id\" = \"demo\".\"min_id\"))\r\n )\r\n)\r\n```\r\n",
"Thanks to @iksteen for his fix in #1839. This is now resolved.",
"Thanks @coleifer and @iksteen!"
] | 2018-12-10T23:35:29 | 2019-01-30T20:37:15 | 2019-01-30T18:26:17 | NONE | null | Hey, thank for writing this great library!
I'm trying to use a CTE and .count() and it's not clear to me if this is supposed to work:
```py
from peewee import *
import datetime
db = PostgresqlDatabase('peeweetest')
class BaseModel(Model):
class Meta:
database = db
# the user model specifies its fields (or columns) declaratively, like django
class User(BaseModel):
username = CharField()
password = CharField()
email = CharField()
join_date = DateTimeField()
db.create_tables([User])
User.create(username='username', password='password', email='email', join_date=datetime.datetime.now())
q1 = User.select()
print(list(q1.execute()))
print(q1.count())
cte = User.select().cte('users')
q2 = User.select().join(cte, on=(User.id == cte.c.id)).with_cte(cte)
print(list(q2.execute()))
print(q2.count())
```
The `q2.count()` query looks like
`SELECT COUNT(1) FROM WITH "users" AS ((SELECT "t1"."id" FROM "user" AS "t1")) (SELECT 1 FROM "user" AS "t2" INNER JOIN "users" ON ("t2"."id" = "users"."id")) AS "_wrapped"`
where I would have expected
`WITH "users" AS ((SELECT "t1"."id" FROM "user" AS "t1")) SELECT COUNT(1) FROM (SELECT 1 FROM "user" AS "t2" INNER JOIN "users" ON ("t2"."id" = "users"."id")) AS "_wrapped"`
```
pip show peewee
Name: peewee
Version: 3.7.1
Summary: a little orm
```
The docs do indeed say that .count() here will just wrap it in a COUNT thing, but I would have expected it to wrap more like my second query there. Am I calling count() wrong? | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1809/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1809/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1808 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1808/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1808/comments | https://api.github.com/repos/coleifer/peewee/issues/1808/events | https://github.com/coleifer/peewee/issues/1808 | 389,410,427 | MDU6SXNzdWUzODk0MTA0Mjc= | 1,808 | Migrator missing not null column during column removal | {
"login": "frdfsnlght",
"id": 417767,
"node_id": "MDQ6VXNlcjQxNzc2Nw==",
"avatar_url": "https://avatars.githubusercontent.com/u/417767?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/frdfsnlght",
"html_url": "https://github.com/frdfsnlght",
"followers_url": "https://api.github.com/users/frdfsnlght/followers",
"following_url": "https://api.github.com/users/frdfsnlght/following{/other_user}",
"gists_url": "https://api.github.com/users/frdfsnlght/gists{/gist_id}",
"starred_url": "https://api.github.com/users/frdfsnlght/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/frdfsnlght/subscriptions",
"organizations_url": "https://api.github.com/users/frdfsnlght/orgs",
"repos_url": "https://api.github.com/users/frdfsnlght/repos",
"events_url": "https://api.github.com/users/frdfsnlght/events{/privacy}",
"received_events_url": "https://api.github.com/users/frdfsnlght/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"Oh, I should have mentioned, I'm using SQLite.",
"Ahh, yeah, its these lines that are causing the issue:\r\n\r\nhttps://github.com/coleifer/peewee/blob/3634aea5ece71e21a2ac5cdb2b74b194e8257960/playhouse/migrate.py#L682-L685",
"It appears that if I rename my 'primaryName' column, the problem goes away (as long as the new name doesn't start with 'primary' (or 'foreign')).\r\n\r\nI suppose I could do that, but of course it will be a PITA.\r\n\r\nFor now, I implemented raw ALTER TABLEs as necessary. I'll have to think this over and figure out if it's worth renaming the column.\r\n",
"Fixed in 1e00d33"
] | 2018-12-10T17:35:47 | 2018-12-10T22:28:09 | 2018-12-10T22:28:09 | NONE | null | I have a model I've been using successfully for while:
```python
class Drink(Model):
primaryName = CharField()
secondaryName = CharField(null = True)
glass = ForeignKeyField(Glass, backref = 'drinks')
instructions = TextField(null = True)
isFavorite = BooleanField(default = False)
isAlcoholic = BooleanField(default = True)
isOnMenu = BooleanField(default = False)
timesDispensed = IntegerField(default = 0)
source = CharField(default = 'local')
createdDate = DateTimeField(default = datetime.datetime.now)
updatedDate = DateTimeField(default = datetime.datetime.now)
```
I'm trying to remove and add some columns with the migrator:
```python
drink_numIngredients = IntegerField(default = 0)
drink_numIngredientsAvailable = IntegerField(null = True)
migrate(
migrator.drop_column('drink', 'createdDate'),
migrator.drop_column('drink', 'updatedDate'),
migrator.add_column('drink', 'numIngredients', drink_numIngredients),
migrator.add_column('drink', 'numIngredientsAvailable', drink_numIngredientsAvailable),
)
```
I have debug logging turned on and I can see this right before the exception:
```
2018-12-10 12:19:23,249 [MainThread] [peewee] [DEBUG]: ('CREATE TABLE "drink__tmp__" ("id" INTEGER NOT NULL PRIMARY KEY, "primaryName" VARCHAR(255) NOT NULL, "secondaryName" VARCHAR(255), "glass_id" INTEGER NOT NULL, "instructions" TEXT, "isFavorite" INTEGER NOT NULL, "isAlcoholic" INTEGER NOT NULL, "isOnMenu" INTEGER NOT NULL, "timesDispensed" INTEGER NOT NULL, "updatedDate" DATETIME NOT NULL, "source" VARCHAR(255) NOT NULL, FOREIGN KEY ("glass_id") REFERENCES "glass" ("id"))', [])
2018-12-10 12:19:23,251 [MainThread] [peewee] [DEBUG]: ('INSERT INTO "drink__tmp__" ("id", "secondaryName", "glass_id", "instructions", "isFavorite", "isAlcoholic", "isOnMenu", "timesDispensed", "updatedDate", "source") SELECT "id", "secondaryName", "glass_id", "instructions", "isFavorite", "isAlcoholic", "isOnMenu", "timesDispensed", "updatedDate", "source" FROM "drink"', [])
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/peewee.py", line 2653, in execute_sql
cursor.execute(sql, params or ())
sqlite3.IntegrityError: NOT NULL constraint failed: drink__tmp__.primaryName
```
I can see the 'createdDate' column is removed during the temp table creation, and then peewee wants to fill the temp table with the data from the original, but it doesn't include the 'primaryName' column in the select resulting in the NOT NULL constraint failure.
Any ideas?
| {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1808/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1808/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1807 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1807/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1807/comments | https://api.github.com/repos/coleifer/peewee/issues/1807/events | https://github.com/coleifer/peewee/issues/1807 | 388,782,292 | MDU6SXNzdWUzODg3ODIyOTI= | 1,807 | Backref of ManyToManyField does not respect through_model foreign keys | {
"login": "albireox",
"id": 568775,
"node_id": "MDQ6VXNlcjU2ODc3NQ==",
"avatar_url": "https://avatars.githubusercontent.com/u/568775?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/albireox",
"html_url": "https://github.com/albireox",
"followers_url": "https://api.github.com/users/albireox/followers",
"following_url": "https://api.github.com/users/albireox/following{/other_user}",
"gists_url": "https://api.github.com/users/albireox/gists{/gist_id}",
"starred_url": "https://api.github.com/users/albireox/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/albireox/subscriptions",
"organizations_url": "https://api.github.com/users/albireox/orgs",
"repos_url": "https://api.github.com/users/albireox/repos",
"events_url": "https://api.github.com/users/albireox/events{/privacy}",
"received_events_url": "https://api.github.com/users/albireox/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"Not sure if it's the correct solution but it seems that making\r\n\r\n```python\r\n return (ManyToManyQuery(instance, self, self.rel_model)\r\n .join(self.through_model)\r\n .join(self.model)\r\n .where(self.src_fk == getattr(instance, self.src_fk.rel_field.name)))\r\n```\r\n\r\nin `ManyToManyFieldAccessor` fixes the problem.",
"As you noted, the issue is that the field \"designation\" on `TwoMassPsc` is not the primary key:\r\n\r\n```python\r\n tmass_source = ForeignKeyField(TwoMassPsc,\r\n column_name='original_ext_source_id',\r\n field='designation',\r\n backref='gaia_best_neighbour')\r\n```\r\n\r\nI'll repeat the strong admonition from the documentation here, just in case someone comes across this in the future:\r\n\r\n> Peewee provides a field for representing many-to-many relationships, much like Django does. This feature was added due to many requests from users, but I strongly advocate against using it, since it conflates the idea of a field with a junction table and *hidden joins*. It’s just a nasty hack to provide convenient accessors.\r\n\r\nThe emphasis (added) is that for all but the simplest use-cases, you're going to have a better time just using a junction model.\r\n\r\nAgain, I do think that this is a legit bug and I will patch it, but I'd suggest that unless you're doing very basic/plain many-to-many queries, you should always prefer the explicit junction table."
] | 2018-12-07T19:22:54 | 2018-12-07T22:33:13 | 2018-12-07T22:33:13 | NONE | null | I have a database with two tables, `GaiaDR2Source` and `TwoMassPsc`, and a cross-match/relation table, `GaiaDR2TmassBestNeighbour`. In `GaiaDR2Source` I create a many-to-many relation using `GaiaDR2TmassBestNeighbour` as through model. The match happens using `GaiaDR2Source.source_id` (which is the pk) and `TwoMassPsc.designation` (which is *not* the pk). My models look like it (I have removed everything that is not relevant):
```python
class TwoMassPsc(SDSS5dbModel):
designation = CharField(null=True, unique=True)
class Meta:
table_name = 'twomass_psc'
schema = 'catalogdb'
GaiaDR2TmassBestNeighbourDeferred = DeferredThroughModel()
class GaiaDR2Source(SDSS5dbModel):
source_id = BigAutoField(primary_key=True)
tmass_best_sources = ManyToManyField(TwoMassPsc,
through_model=GaiaDR2TmassBestNeighbourDeferred,
backref='gaia_best_sources')
class Meta:
table_name = 'gaia_dr2_source'
schema = 'catalogdb'
class GaiaDR2TmassBestNeighbour(SDSS5dbModel):
source_id = BigAutoField(primary_key=True)
original_ext_source_id = CharField(null=True)
gaia_source = ForeignKeyField(GaiaDR2Source,
column_name='source_id',
backref='tmass_best_neighbour')
tmass_source = ForeignKeyField(TwoMassPsc,
column_name='original_ext_source_id',
field='designation',
backref='gaia_best_neighbour')
class Meta:
table_name = 'gaiadr2_tmass_best_neighbour'
schema = 'catalogdb'
GaiaDR2TmassBestNeighbourDeferred.set_model(GaiaDR2TmassBestNeighbour)
```
The foreign keys from `GaiaDR2TmassBestNeighbour` to either other table work fine, as it does going from `GaiaDR2Source` to `TwoMassPsc`, e.g.:
```python
>>> gg = GaiaDR2Source.get()
>>> gg.tmass_best_sources[0]
<TwoMassPsc: 264047591>
```
but the backers fails
```python
>>> tt = TwoMassPsc.get()
>>> tt.gaia_best_sources[0]
IndexError: list index out of range
```
Looking at the raw SQL that it tries to run I see that it's trying to use join the through model using the primary key of `TwoMassPsc` instead of the `designation` field, as instructed in the foreign key. | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1807/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1807/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1806 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1806/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1806/comments | https://api.github.com/repos/coleifer/peewee/issues/1806/events | https://github.com/coleifer/peewee/issues/1806 | 388,526,357 | MDU6SXNzdWUzODg1MjYzNTc= | 1,806 | DeferredManyToManyField | {
"login": "albireox",
"id": 568775,
"node_id": "MDQ6VXNlcjU2ODc3NQ==",
"avatar_url": "https://avatars.githubusercontent.com/u/568775?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/albireox",
"html_url": "https://github.com/albireox",
"followers_url": "https://api.github.com/users/albireox/followers",
"following_url": "https://api.github.com/users/albireox/following{/other_user}",
"gists_url": "https://api.github.com/users/albireox/gists{/gist_id}",
"starred_url": "https://api.github.com/users/albireox/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/albireox/subscriptions",
"organizations_url": "https://api.github.com/users/albireox/orgs",
"repos_url": "https://api.github.com/users/albireox/repos",
"events_url": "https://api.github.com/users/albireox/events{/privacy}",
"received_events_url": "https://api.github.com/users/albireox/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"As you noticed, there's no such thing as a `DeferredManyToManyField`, nor do I think there needs to be. Remember that a many-to-many is just a junction table with foreign-keys to the table(s) being related via many-to-many. To use my favorite example,\r\n\r\n```python\r\n\r\nclass Student(Model):\r\n name = TextField()\r\n # courses = ManyToManyField(Course) ??? there's no need to do this.\r\n\r\nclass Course(Model):\r\n name = TextField()\r\n students = ManyToManyField(Student) # do this instead. many-to-many is symmetrical.\r\n\r\n# Or, better yet, don't use ManyToManyField at all and just:\r\nclass CourseStudent(Model):\r\n course = ForeignKeyField(Course)\r\n student = ForeignKeyField(Student)\r\n```\r\n\r\n> I wonder if it'd possible to add a `through_model` keyword to both `ForeignKeyField` and `DeferredForeignKey` which, if set, would make the foreign key behave as a `ManyToManyField`.\r\n\r\nZen of Python:\r\n\r\n> Special cases aren't special enough to break the rules.\r\n> ...\r\n> There should be one-- and preferably only one --obvious way to do it. "
] | 2018-12-07T06:44:54 | 2018-12-07T21:32:48 | 2018-12-07T21:32:47 | NONE | null | I hit a case in which I'd have liked to be able to use a `DeferredManyToManyField` with a `DeferredThroughModel`. In my case I was able to fix it rearranging the order of the model classes so that the `ManyToManyField` would not need to point to a deferred model, but I wonder if that will always be the case.
Ultimately, and to make things a bit cleaner, I wonder if it'd possible to add a `through_model` keyword to both `ForeignKeyField` and `DeferredForeignKey` which, if set, would make the foreign key behave as a `ManyToManyField`. | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1806/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1806/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1805 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1805/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1805/comments | https://api.github.com/repos/coleifer/peewee/issues/1805/events | https://github.com/coleifer/peewee/issues/1805 | 388,467,967 | MDU6SXNzdWUzODg0Njc5Njc= | 1,805 | ManyToManyField and backref='+' fails | {
"login": "albireox",
"id": 568775,
"node_id": "MDQ6VXNlcjU2ODc3NQ==",
"avatar_url": "https://avatars.githubusercontent.com/u/568775?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/albireox",
"html_url": "https://github.com/albireox",
"followers_url": "https://api.github.com/users/albireox/followers",
"following_url": "https://api.github.com/users/albireox/following{/other_user}",
"gists_url": "https://api.github.com/users/albireox/gists{/gist_id}",
"starred_url": "https://api.github.com/users/albireox/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/albireox/subscriptions",
"organizations_url": "https://api.github.com/users/albireox/orgs",
"repos_url": "https://api.github.com/users/albireox/repos",
"events_url": "https://api.github.com/users/albireox/events{/privacy}",
"received_events_url": "https://api.github.com/users/albireox/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"From the [documentation](http://docs.peewee-orm.com/en/latest/peewee/relationships.html#manytomany):\r\n\r\n> Peewee provides a field for representing many-to-many relationships, much like Django does. This feature was added due to many requests from users, but I strongly advocate against using it, since it conflates the idea of a field with a junction table and hidden joins. It’s just a nasty hack to provide convenient accessors.\r\n\r\nRegarding the backref ... I'm not sure I completely understand, but it appears to me that disabling the backref on the ManyToManyField works correctly:\r\n\r\n```python\r\nclass Student(Model):\r\n name = TextField()\r\n\r\nclass Course(Model):\r\n name = TextField()\r\n students = ManyToManyField(Student, backref='+')\r\n\r\nCourseStudent = Course.students.get_through_model()\r\n\r\n# ...\r\n# It seems to work fine to use the `course.students` many-to-many accessor:\r\nmath = Course.create(name='math')\r\ns = Student.create(name='s')\r\nmath.students.add(s) # Works.\r\nlist(math.students) # Works, returns [<Student: 1>]\r\n```\r\n\r\nAnd, as it would suggest, there is no backref on the `Student` model, e.g. there's no `student.courses` backref.\r\n\r\n-------------------------\r\n\r\nIf you're talking about manually declaring a through-model with backrefs disabled on both sides...I have to ask: what are you even bothering with using `ManyToManyField` for?\r\n\r\nI'm not saying there's not a bug in the code. I am, however, suggesting that you're making a foolish choice to try and use ManyToManyField for anything but the most trivial many-to-many implementations."
] | 2018-12-07T01:28:07 | 2018-12-07T21:25:16 | 2018-12-07T21:25:16 | NONE | null | It seems that if you have a `ManyToManyField` that uses a through model in which the foreign keys are defined with `backref='+'` it fails when trying to access the many-to-many field because it still tries to access the backref. The error is
```python
~/.pyenv/versions/3.7.1/Python.framework/Versions/3.7/lib/python3.7/site-packages/peewee.py in __get__(self, instance, instance_type, force_query)
4609 def __get__(self, instance, instance_type=None, force_query=False):
4610 if instance is not None:
-> 4611 if not force_query and isinstance(getattr(instance, self.src_fk.backref), list):
4612 return [getattr(obj, self.dest_fk.name) for obj in getattr(instance, self.src_fk.backref)]
4613 else:
AttributeError: 'Target' object has no attribute '+'
``` | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1805/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1805/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1804 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1804/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1804/comments | https://api.github.com/repos/coleifer/peewee/issues/1804/events | https://github.com/coleifer/peewee/issues/1804 | 388,122,545 | MDU6SXNzdWUzODgxMjI1NDU= | 1,804 | AttributeError: 'ValuesList' object has no attribute '_hash' | {
"login": "lephuongbg",
"id": 1001176,
"node_id": "MDQ6VXNlcjEwMDExNzY=",
"avatar_url": "https://avatars.githubusercontent.com/u/1001176?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/lephuongbg",
"html_url": "https://github.com/lephuongbg",
"followers_url": "https://api.github.com/users/lephuongbg/followers",
"following_url": "https://api.github.com/users/lephuongbg/following{/other_user}",
"gists_url": "https://api.github.com/users/lephuongbg/gists{/gist_id}",
"starred_url": "https://api.github.com/users/lephuongbg/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/lephuongbg/subscriptions",
"organizations_url": "https://api.github.com/users/lephuongbg/orgs",
"repos_url": "https://api.github.com/users/lephuongbg/repos",
"events_url": "https://api.github.com/users/lephuongbg/events{/privacy}",
"received_events_url": "https://api.github.com/users/lephuongbg/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"What's the actual error? \"ValuesList has no attribute source\"?\r\n\r\nedit: nevermind, replicated \"AttributeError: 'ValuesList' object has no attribute '_hash'\""
] | 2018-12-06T09:20:29 | 2018-12-06T15:46:45 | 2018-12-06T15:46:45 | NONE | null | I'm trying to filter valid ids from a list of ids like this:
```python
ids = [(1,), (2,), (3,)]
values = ValuesList(ids, ('id',), alias='ids')
list(Users.select(values.c.id)
.join(values, p.JOIN.RIGHT_OUTER, cls.id == values.c.id)
.where(cls.id.is_null()))
```
Produced SQL is OK but as soon as the query returns any results:
```
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/var/task/.venv/src/peewee/peewee.py", line 3726, in __len__
self.fill_cache()
File "/var/task/.venv/src/peewee/peewee.py", line 3767, in fill_cache
iterator.next()
File "/var/task/.venv/src/peewee/peewee.py", line 3823, in next
self.cursor_wrapper.iterate()
File "/var/task/.venv/src/peewee/peewee.py", line 3739, in iterate
self.initialize() # Lazy initialization.
File "/var/task/.venv/src/peewee/peewee.py", line 6555, in initialize
self._initialize_columns()
File "/var/task/.venv/src/peewee/peewee.py", line 6485, in _initialize_columns
if isinstance(node, Column) and node.source == table:
```
| {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1804/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1804/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1803 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1803/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1803/comments | https://api.github.com/repos/coleifer/peewee/issues/1803/events | https://github.com/coleifer/peewee/pull/1803 | 387,626,821 | MDExOlB1bGxSZXF1ZXN0MjM2MDcyMzU4 | 1,803 | Support order by in aggregate function | {
"login": "lephuongbg",
"id": 1001176,
"node_id": "MDQ6VXNlcjEwMDExNzY=",
"avatar_url": "https://avatars.githubusercontent.com/u/1001176?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/lephuongbg",
"html_url": "https://github.com/lephuongbg",
"followers_url": "https://api.github.com/users/lephuongbg/followers",
"following_url": "https://api.github.com/users/lephuongbg/following{/other_user}",
"gists_url": "https://api.github.com/users/lephuongbg/gists{/gist_id}",
"starred_url": "https://api.github.com/users/lephuongbg/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/lephuongbg/subscriptions",
"organizations_url": "https://api.github.com/users/lephuongbg/orgs",
"repos_url": "https://api.github.com/users/lephuongbg/repos",
"events_url": "https://api.github.com/users/lephuongbg/events{/privacy}",
"received_events_url": "https://api.github.com/users/lephuongbg/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"My own sense is that this is a niche usage and not widely supported.\r\n\r\nRather than implement a special-case for this, I'll suggest using `NodeList` and `SQL` to compose the appropriate \"ORDER BY\" clause.",
"Could you give an example on how to use NodeList with `fn`? Because for me:\r\n+ `fn` wraps its arguments with parens and,\r\n+ I couldn't figure out how to put `NodeList` as `fn` argument. ",
"```sql\r\nSELECT array_agg(\r\n \"t1\".\"name\" ORDER BY \"t1\".\"name\" ASC, \"t1\".\"created_at\" DESC\r\n) AS \"users\" \r\n```\r\n\r\n```python\r\nname_asc = NodeList((User.name, SQL('ORDER BY'), User.name.asc()))\r\n...select(fn.array_agg(name_asc, User.created_at.desc()).alias('users'))\r\n```",
"That's much harder to look at. Guess I just have to maintain a subclass in my code.\r\n\r\nBy the way, what do you think are the cons of supporting this in `fn`?"
] | 2018-12-05T07:29:52 | 2018-12-05T22:27:23 | 2018-12-05T14:31:33 | NONE | null | PostgreSQL support ORDER BY in aggregate function (e.g `json_agg`, `array_agg`, etc.) like this:
```SQL
SELECT array_agg(
"t1"."name" ORDER BY "t1"."name" ASC, "t1"."created_at" DESC
) AS "users"
FROM "users" AS "t1"
```
This PR extend `fn` API to support this kind of query.
```
fn.array_agg(User.name).order_by(User.name.asc(), User.created_at.desc())
``` | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1803/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1803/timeline | null | null | false | {
"url": "https://api.github.com/repos/coleifer/peewee/pulls/1803",
"html_url": "https://github.com/coleifer/peewee/pull/1803",
"diff_url": "https://github.com/coleifer/peewee/pull/1803.diff",
"patch_url": "https://github.com/coleifer/peewee/pull/1803.patch",
"merged_at": null
} |
https://api.github.com/repos/coleifer/peewee/issues/1802 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1802/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1802/comments | https://api.github.com/repos/coleifer/peewee/issues/1802/events | https://github.com/coleifer/peewee/issues/1802 | 387,549,037 | MDU6SXNzdWUzODc1NDkwMzc= | 1,802 | how to select a random row with a group by clause in peewee | {
"login": "Colaplusice",
"id": 29660460,
"node_id": "MDQ6VXNlcjI5NjYwNDYw",
"avatar_url": "https://avatars.githubusercontent.com/u/29660460?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/Colaplusice",
"html_url": "https://github.com/Colaplusice",
"followers_url": "https://api.github.com/users/Colaplusice/followers",
"following_url": "https://api.github.com/users/Colaplusice/following{/other_user}",
"gists_url": "https://api.github.com/users/Colaplusice/gists{/gist_id}",
"starred_url": "https://api.github.com/users/Colaplusice/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/Colaplusice/subscriptions",
"organizations_url": "https://api.github.com/users/Colaplusice/orgs",
"repos_url": "https://api.github.com/users/Colaplusice/repos",
"events_url": "https://api.github.com/users/Colaplusice/events{/privacy}",
"received_events_url": "https://api.github.com/users/Colaplusice/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"the question has been asked in stackoverflow : [link](https://stackoverflow.com/questions/28514736/how-to-select-a-random-row-with-a-group-by-clause) ,but i don't know how to translate it to peewee. please help me...\r\ni am stuck in there for a long time.\r\n",
"It can be done like this:\r\n\r\n```python\r\nobjects_tbl = Table('objects')\r\nimages_tbl = Table('images')\r\nsubquery = (objects_tbl\r\n .select(images_tbl.c.image_path,\r\n objects_tbl.c.id.alias('object_id'),\r\n objects_tbl.c.name)\r\n .order_by(SQL('RAND()'))\r\n .join(images_tbl, join_type=JOIN.LEFT_OUTER, on=images_tbl.c.object_id == objects_tbl.c.id)\r\n .alias('z'))\r\nquery = (Select().select(subquery.c.object_id, subquery.c.name,\r\n subquery.c.image_path)\r\n .from_(subquery)\r\n .group_by(subquery.c.object_id, subquery.c.name))\r\n```\r\n\r\nOutput:\r\n```SQL\r\n--- query.sql()\r\nSELECT \"z\".\"object_id\", \"z\".\"name\", \"z\".\"image_path\" \r\nFROM (\r\n SELECT \"t1\".\"image_path\", \"t2\".\"id\" AS \"object_id\", \"t2\".\"name\" \r\n FROM \"objects\" AS \"t2\" \r\n LEFT OUTER JOIN \"images\" AS \"t1\" ON (\"t1\".\"object_id\" = \"t2\".\"id\") \r\n ORDER BY RAND()\r\n) AS \"z\" GROUP BY \"z\".\"object_id\", \"z\".\"name\"\r\n```",
"yeah, thank you very much, i solved the problem about 30 mininutes ago。 I found the answer in [charlesleifer.com/blog](http://charlesleifer.com/blog/querying-the-top-n-objects-per-group-with-peewee-orm/)\r\nmy code is this:\r\n\r\n```\r\n random_query = (\r\n Sentence.select(Sentence, Level.difficulty)\r\n .join(Level, on=(Sentence.level_id == Level.id))\r\n .order_by(pw.fn.Rand())\r\n .where(\r\n Sentence.status == ResourceStatus.PUBLISHED,\r\n Level.status == ResourceStatus.PUBLISHED,\r\n )\r\n )\r\n sentences = (\r\n Sentence.select(\r\n random_query.c.status,\r\n random_query.c.content,\r\n random_query.c.id,\r\n random_query.c.level_id,\r\n )\r\n .from_(random_query)\r\n .group_by(random_query.c.difficulty)\r\n )\r\n```\r\n\r\nthank you very much~\r\n\r\n\r\n",
"That's great. Then we should also close the issue.",
"Good stuff, yep that example looks good."
] | 2018-12-05T01:07:55 | 2018-12-05T14:34:13 | 2018-12-05T10:09:48 | NONE | null | like this: select object_id, name, image_path
from
(SELECT images.image_path AS image_path, objects.id AS object_id, objects.name
FROM objects LEFT JOIN images ON images.object_id = objects.id
ORDER BY RAND()) as z
group by z.object_id, z.name | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1802/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1802/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1801 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1801/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1801/comments | https://api.github.com/repos/coleifer/peewee/issues/1801/events | https://github.com/coleifer/peewee/issues/1801 | 387,308,767 | MDU6SXNzdWUzODczMDg3Njc= | 1,801 | Using sub-select as operand in expression applies a table alias to the sub-select | {
"login": "iksteen",
"id": 1001206,
"node_id": "MDQ6VXNlcjEwMDEyMDY=",
"avatar_url": "https://avatars.githubusercontent.com/u/1001206?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/iksteen",
"html_url": "https://github.com/iksteen",
"followers_url": "https://api.github.com/users/iksteen/followers",
"following_url": "https://api.github.com/users/iksteen/following{/other_user}",
"gists_url": "https://api.github.com/users/iksteen/gists{/gist_id}",
"starred_url": "https://api.github.com/users/iksteen/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/iksteen/subscriptions",
"organizations_url": "https://api.github.com/users/iksteen/orgs",
"repos_url": "https://api.github.com/users/iksteen/repos",
"events_url": "https://api.github.com/users/iksteen/events{/privacy}",
"received_events_url": "https://api.github.com/users/iksteen/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"Hmm, it seems that if I use `CompoundSelectQuery` (which isn't imported using `from peewee import *`), it does work.\r\n\r\nIs that the intended way to solve the problem?\r\n\r\nEdit: I guess not, because trying to use a correlated subquery will create a new alias for the original table,",
"Is there a situation possible where either side of an expression can be aliased? I personally can't think of any, and if that is a correct assumption, the `in_op` context variable introduced by the fix for #1716 could be extended to include all operations (and `in_op` could be renamed to `in_expr`).",
"You might notice that some operands will appear to work when the right-hand-side is a query object, but others will not work if the query is on the left-hand-side. This is because queries are not treated as column-like objects (even though in your example you are using a query as a column-like value). Furthermore in some cases attempting to use a query on the left-hand-side will result in the generation of JOIN clauses, since table-like objects (such as queries) implement operator overloads for representing JOINs...e.g. query1 + query2 == query1 UNION ALL query2.\r\n\r\nIts not quite clear to me that creating a correlated subquery is the issue, as I've added test-cases showing that its possible: e321a23be4ac9c5bb42af9e460a980ef5e408214\r\n\r\nThe problem seems to arise when attempting to use a correlated subquery in an expression... Could you achieve what you're attempting by just using a join and aggregate instead?",
"Original:\r\n```python\r\ndecayed_score = Challenge.select(\r\n Challenge.points / Team.select(fn.count(Team.id) + 1)\r\n)\r\n```\r\n\r\nAlternative:\r\n\r\n```python\r\nquery = Challenge.select(Challenge.points / fn.COUNT(Team.id) + 1).join(Team, JOIN.LEFT_OUTER).group_by(...)\r\n```",
"Ah right, unions could have an alias.\n\nAnd yes, in this small example the aggregation that would work.. but it wouldn't fit my monster query (which I'm too afraid and ashamed to show).\n\nHowever, by you having me rethink my method, you put me on a path where I think I can rewrite that monster query using CTEs where I won't wouldn't run into this issue.\n\nThat makes the issue not invalid, but feel free to close it anyway.",
"Think this is now resolved: fb41bfcbc68b87ab315dfbf8a2c935a4b3eda1c8",
":+1: That's exactly the way I got it to work locally (well, minus the parentheses rework).\r\n\r\nBetween you and me, this is my query now (please don't hate me): https://plak.infrapuin.nl/0bnaddnw.py This new commit allows me to get rid of the `team_count` cte."
] | 2018-12-04T14:21:00 | 2018-12-14T12:16:46 | 2018-12-14T11:57:54 | NONE | null | Consider the following (simplified) example where I want to divide a value by the result of a subquery (in the actual use case the points will decay based on how many teams solved a challenge correctly):
```
import logging
from peewee import *
logging.basicConfig(level=logging.DEBUG)
database = PostgresqlDatabase('scoreboard')
class Base(Model):
class Meta:
database = database
class Team(Base):
name = TextField(unique=True)
class Challenge(Base):
flag = TextField(unique=True)
points = IntegerField()
decayed_score = Challenge.select(
Challenge.points / Team.select(fn.count(Team.id) + 1)
)
for row in decayed_score:
print(row)
```
Running this example results in the following query:
```
DEBUG:peewee:('SELECT ("t1"."points" / (SELECT (count("t2"."id") + %s) FROM "team" AS "t2") AS "t3") FROM "challenge" AS "t1"', [1])
```
The alias applied to the subquery (`T3`) results in the following error:
```
peewee.ProgrammingError: syntax error at or near "AS"
LINE 1: ...ELECT (count("t2"."id") + 1) FROM "team" AS "t2") AS "t3") F...
^
``` | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1801/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1801/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1800 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1800/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1800/comments | https://api.github.com/repos/coleifer/peewee/issues/1800/events | https://github.com/coleifer/peewee/pull/1800 | 386,373,809 | MDExOlB1bGxSZXF1ZXN0MjM1MTMzODc5 | 1,800 | Introspector: Don't strip _id unless foreign key | {
"login": "cognifloyd",
"id": 1558590,
"node_id": "MDQ6VXNlcjE1NTg1OTA=",
"avatar_url": "https://avatars.githubusercontent.com/u/1558590?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/cognifloyd",
"html_url": "https://github.com/cognifloyd",
"followers_url": "https://api.github.com/users/cognifloyd/followers",
"following_url": "https://api.github.com/users/cognifloyd/following{/other_user}",
"gists_url": "https://api.github.com/users/cognifloyd/gists{/gist_id}",
"starred_url": "https://api.github.com/users/cognifloyd/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/cognifloyd/subscriptions",
"organizations_url": "https://api.github.com/users/cognifloyd/orgs",
"repos_url": "https://api.github.com/users/cognifloyd/repos",
"events_url": "https://api.github.com/users/cognifloyd/events{/privacy}",
"received_events_url": "https://api.github.com/users/cognifloyd/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"Closing as a roughly equivalent patch was merged instead."
] | 2018-11-30T22:27:17 | 2018-12-02T18:11:47 | 2018-12-02T18:11:47 | NONE | null | This avoids stripping _id from a field name when introspecting a table,
unless that column is a foreign key.
Resolves #1799
This is a quick hack and should probably also change the interface of `introspect()` and `generate_models()` to include some new parameter. | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1800/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1800/timeline | null | null | false | {
"url": "https://api.github.com/repos/coleifer/peewee/pulls/1800",
"html_url": "https://github.com/coleifer/peewee/pull/1800",
"diff_url": "https://github.com/coleifer/peewee/pull/1800.diff",
"patch_url": "https://github.com/coleifer/peewee/pull/1800.patch",
"merged_at": null
} |
https://api.github.com/repos/coleifer/peewee/issues/1799 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1799/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1799/comments | https://api.github.com/repos/coleifer/peewee/issues/1799/events | https://github.com/coleifer/peewee/issues/1799 | 386,341,173 | MDU6SXNzdWUzODYzNDExNzM= | 1,799 | feature request: Introspector.make_column_name should have different logic for foreign key fields | {
"login": "cognifloyd",
"id": 1558590,
"node_id": "MDQ6VXNlcjE1NTg1OTA=",
"avatar_url": "https://avatars.githubusercontent.com/u/1558590?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/cognifloyd",
"html_url": "https://github.com/cognifloyd",
"followers_url": "https://api.github.com/users/cognifloyd/followers",
"following_url": "https://api.github.com/users/cognifloyd/following{/other_user}",
"gists_url": "https://api.github.com/users/cognifloyd/gists{/gist_id}",
"starred_url": "https://api.github.com/users/cognifloyd/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/cognifloyd/subscriptions",
"organizations_url": "https://api.github.com/users/cognifloyd/orgs",
"repos_url": "https://api.github.com/users/cognifloyd/repos",
"events_url": "https://api.github.com/users/cognifloyd/events{/privacy}",
"received_events_url": "https://api.github.com/users/cognifloyd/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"In some databases people don't use actual foreign-key constraints, especially SQLite and MySQL. Additionally, introspecting a column named \"foo_id\", regardless of whether or not its a foreign-key, I think it's a reasonable assumption that we assume the Pythonic name should be \"foo\".\r\n\r\nThat being said, there's also the case of an externally-managed ID. Say you're caching some response data from a 3rd-party API and want to store a user_id that has no reference to anything else in your DB. In that case it seems reasonable to retain the \"user_id\" column name and that calling it \"user\" would actually be somewhat misleading.\r\n\r\nAfter giving it some thought, I think I agree with you that this logic should only apply in the case of foreign-keys.",
"Merged a patch that is similar to #1800 but with the following differences:\r\n\r\n* is_foreign_key=False by default (yours has =True)\r\n* has tests \r\n* not O(n) on each column (!!)"
] | 2018-11-30T20:36:34 | 2018-12-02T18:11:19 | 2018-12-02T18:10:32 | NONE | null | I'm using peewee to access another application's database. To avoid writing the models for the db, I'm using `playhouse.reflection.Introspector.generate_models()`. In this database, some of the tables use the suffix `_id` on the primary key column. Then, other tables that have a foreign key reference to that table use the same column name (with the `_id` suffix) to reference the other table.
As is, peewee is stripping the `_id` suffix whether the column has a foreign key constraint or not. I would like the ability to tell the `Introspector` to only strip the `_id` suffix on foreign key fields.
Here's a fun example:
A database named `dr_seuss.db` has several tables such as
- a table `things` with primary key `thing_id`, and
- a table `cats_things_map` with a column `thing_id`
`cats_things_map.thing_id` has a foreign key constraint on `things.thing_id`.
(there would of course be two entries in a `cats_things_map` where ["The Cat in the Hat"](https://en.wikipedia.org/wiki/The_Cat_in_the_Hat) would have a one to many relation with "Thing One" and "Thing Two")
In this case, I would like the `playhouse.reflection.Introspector` to give me models like this:
- `cats_things_map` should have two fields `thing` and `thing_id`, where `thing` is the orm injected object from the `things` model, and `thing_id` is the actual id of that object. _peewee already does this_
- `things` should have a `thing_id` field (NOT `thing`) that maps to the `thing_id` column contents (the primary key). _peewee does not currently let me skip stripping `_id` on columns that are not foreign-key-constrained_
Is there a way that either `make_column_name` can differentiate columns with foreign key constraints?
https://github.com/coleifer/peewee/blob/d31e7bf972e69e227c10694fac71b966959e715f/playhouse/reflection.py#L485-L492
It looks like foreign keys should be available in `foreign_keys[table]` where this is used in `Introspector.introspect()` here:
https://github.com/coleifer/peewee/blob/d31e7bf972e69e227c10694fac71b966959e715f/playhouse/reflection.py#L545-L549
And I use `Introspect.introspect()` indirectly via `Introspect.generate_models()` here. So I would need a flag called something like `literal_column_names_unless_foreign_key` (an awful name - but similar to `literal_column_names`) that gets passed from `generate_models()` to `introspect()`:
https://github.com/coleifer/peewee/blob/d31e7bf972e69e227c10694fac71b966959e715f/playhouse/reflection.py#L615-L619
I thought about using `literal_column_names` but then the foreign key fields end up as `thing_id` and `thing_id_id` which is also not as clean an interface for me.
context: I'm actually doing config management on that application and the config has to be in the db.
I avoid dipping into another application's database as much as possible, but peewee makes it easier to dip in when no other mechanism exists in the app to access or manage the info I need.
The Introspector lets me gloss over most of the schema changes (such as adding a column in version X.Y of the app) and just access the tables and columns I need to. Introspector saves me the maintenance overhead of writing models for multiple versions of the schema. Thanks so much for the Introspector as it allows me to have a much looser coupling on that other app's database. | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1799/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1799/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1798 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1798/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1798/comments | https://api.github.com/repos/coleifer/peewee/issues/1798/events | https://github.com/coleifer/peewee/issues/1798 | 386,180,594 | MDU6SXNzdWUzODYxODA1OTQ= | 1,798 | Specify charset on CharField | {
"login": "tarlogic-osint",
"id": 22524341,
"node_id": "MDQ6VXNlcjIyNTI0MzQx",
"avatar_url": "https://avatars.githubusercontent.com/u/22524341?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/tarlogic-osint",
"html_url": "https://github.com/tarlogic-osint",
"followers_url": "https://api.github.com/users/tarlogic-osint/followers",
"following_url": "https://api.github.com/users/tarlogic-osint/following{/other_user}",
"gists_url": "https://api.github.com/users/tarlogic-osint/gists{/gist_id}",
"starred_url": "https://api.github.com/users/tarlogic-osint/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/tarlogic-osint/subscriptions",
"organizations_url": "https://api.github.com/users/tarlogic-osint/orgs",
"repos_url": "https://api.github.com/users/tarlogic-osint/repos",
"events_url": "https://api.github.com/users/tarlogic-osint/events{/privacy}",
"received_events_url": "https://api.github.com/users/tarlogic-osint/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"I'd typically think it would be better to use UTF8 when creating the database, e.g.:\r\n\r\n```sql\r\nCREATE DATABASE foobar CHARACTER SET utf8 COLLATE utf8_unicode_ci;\r\n```\r\n\r\nI understand the storage concerns, though. You should be able to add the charset as peewee supports arbitrary constraints:\r\n\r\n```python\r\nfield = CharField(constraints=[SQL('CHARACTER SET utf8 COLLATE utf8_unicode_ci')])\r\n```",
"First, thanks for the suggestion.\r\n\r\nI tried to apply the next definition:\r\n```python\r\nname = CharField(unique=True, constraints=[SQL('CHARACTER SET utf8 COLLATE utf8_unicode_ci')])\r\n```\r\n\r\nBut there was an SQL syntax error due the generated SQL , that was something similar to:\r\n\r\n```SQL\r\nCREATE TABLE foo (field VARCHAR(255) NOT NULL CHARACTER SET utf8 COLLATE utf8_unicode_ci);\r\n```\r\n\r\nThe problem comes from the `NOT NULL` which was put before of `CHARACTER SET`. To solve this was necessary to set `NOT NULL` after of charset declaration, in this way:\r\n\r\n```SQL\r\nCREATE TABLE foo (field VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL);\r\n```\r\n\r\nTo achieve the previous sentence from peewee I had to write the next declaration, which it is a bit tricky:\r\n\r\n```python\r\nfield = CharField(unique=True, null=True, constraints=[SQL('CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL')])\r\n```\r\n\r\nSo even if it is possible to reach the desire SQL statement this problem should be revised since my solution is just an ugly hack.\r\n",
"I just realize that `CHARACTER SET` is not available in SQLite, therefore if you put that in constraints parameter the table creation fails in SQLite (due to the generated SQL statement). Thus this is not a valid solution because don't allow to use both SQLite and Mysql in a transparent way. \r\n\r\nI encourage to solve this problem cause I believe that peewee it's a nice tool with a really nice interface, but this kind of issue could make them unusable in several cases.\r\n",
"No, I'm pretty sure this is just a MySQL thing. In postgres you set the encoding on the database. Sqlite is just utf8, as far as I know.\r\n\r\nTypically I think its unusual to specify the charset on just a single column. Usually one would set a default charset on the database or maybe(?) the table."
] | 2018-11-30T13:07:55 | 2018-12-13T15:18:19 | 2018-11-30T15:14:33 | NONE | null | Peewee doesn't allow to specify the charset of CharField.
I want to specify an utf8 charset in some name fields for which I don't need the utf8mb4 charset used by default in Mysql. This also generates problems with Unique indexes generated cause the length of varchars (utf8mb4 makes a char be 4 bytes in size). It throws the error `Specified key was too long; max key length is 767 bytes`.
I would be nice if that option could be included.
| {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1798/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1798/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1797 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1797/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1797/comments | https://api.github.com/repos/coleifer/peewee/issues/1797/events | https://github.com/coleifer/peewee/issues/1797 | 385,671,189 | MDU6SXNzdWUzODU2NzExODk= | 1,797 | MySQL Error 1059(FK identifier name is too long) on migrator.add_column | {
"login": "Dushyant7",
"id": 9477918,
"node_id": "MDQ6VXNlcjk0Nzc5MTg=",
"avatar_url": "https://avatars.githubusercontent.com/u/9477918?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/Dushyant7",
"html_url": "https://github.com/Dushyant7",
"followers_url": "https://api.github.com/users/Dushyant7/followers",
"following_url": "https://api.github.com/users/Dushyant7/following{/other_user}",
"gists_url": "https://api.github.com/users/Dushyant7/gists{/gist_id}",
"starred_url": "https://api.github.com/users/Dushyant7/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/Dushyant7/subscriptions",
"organizations_url": "https://api.github.com/users/Dushyant7/orgs",
"repos_url": "https://api.github.com/users/Dushyant7/repos",
"events_url": "https://api.github.com/users/Dushyant7/events{/privacy}",
"received_events_url": "https://api.github.com/users/Dushyant7/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"Peewee contains code that correctly truncates long index names. I've added a new patch that truncates long foreign-key constraint names, which will be included in the next release.\r\n\r\nYou're using an ancient version, I suggest upgrading."
] | 2018-11-29T10:37:53 | 2018-12-14T19:03:00 | 2018-11-29T15:54:47 | NONE | null | peewee==2.8.1
I am using MySQLMigrator to migrate my tables.
When I am creating new column using add_column which is ForeignKeyField.
It throws `peewee.InternalError (1059, Identifier name ... is too long)`.
The reason behind this is MySQL has limit of 64 characters for FK identifier and identifier name which is created by add_column is more than 64 characters (68 in my case using format "fk_%s_%s_refs_%s").
https://dev.mysql.com/doc/refman/5.7/en/identifiers.html
I am not sure if I can specify such identifier in ForeignKeyField or in add_column function.
Not sure about other, but specific to MySQL, FK identifier name is auto generated in case not specified. This can solve the issue.
There should be some tests for maximum length constraint on identifiers. | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1797/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1797/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1796 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1796/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1796/comments | https://api.github.com/repos/coleifer/peewee/issues/1796/events | https://github.com/coleifer/peewee/pull/1796 | 385,542,543 | MDExOlB1bGxSZXF1ZXN0MjM0NDg5MzQ1 | 1,796 | Fix cast chaining | {
"login": "lephuongbg",
"id": 1001176,
"node_id": "MDQ6VXNlcjEwMDExNzY=",
"avatar_url": "https://avatars.githubusercontent.com/u/1001176?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/lephuongbg",
"html_url": "https://github.com/lephuongbg",
"followers_url": "https://api.github.com/users/lephuongbg/followers",
"following_url": "https://api.github.com/users/lephuongbg/following{/other_user}",
"gists_url": "https://api.github.com/users/lephuongbg/gists{/gist_id}",
"starred_url": "https://api.github.com/users/lephuongbg/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/lephuongbg/subscriptions",
"organizations_url": "https://api.github.com/users/lephuongbg/orgs",
"repos_url": "https://api.github.com/users/lephuongbg/repos",
"events_url": "https://api.github.com/users/lephuongbg/events{/privacy}",
"received_events_url": "https://api.github.com/users/lephuongbg/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"Nice catch, thanks."
] | 2018-11-29T02:34:27 | 2018-11-29T15:24:55 | 2018-11-29T15:24:55 | NONE | null | Will resolve #1795
Please suggest where should I put the test for this. | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1796/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1796/timeline | null | null | false | {
"url": "https://api.github.com/repos/coleifer/peewee/pulls/1796",
"html_url": "https://github.com/coleifer/peewee/pull/1796",
"diff_url": "https://github.com/coleifer/peewee/pull/1796.diff",
"patch_url": "https://github.com/coleifer/peewee/pull/1796.patch",
"merged_at": "2018-11-29T15:24:54"
} |
https://api.github.com/repos/coleifer/peewee/issues/1795 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1795/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1795/comments | https://api.github.com/repos/coleifer/peewee/issues/1795/events | https://github.com/coleifer/peewee/issues/1795 | 385,540,472 | MDU6SXNzdWUzODU1NDA0NzI= | 1,795 | Can not do cast chaining | {
"login": "lephuongbg",
"id": 1001176,
"node_id": "MDQ6VXNlcjEwMDExNzY=",
"avatar_url": "https://avatars.githubusercontent.com/u/1001176?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/lephuongbg",
"html_url": "https://github.com/lephuongbg",
"followers_url": "https://api.github.com/users/lephuongbg/followers",
"following_url": "https://api.github.com/users/lephuongbg/following{/other_user}",
"gists_url": "https://api.github.com/users/lephuongbg/gists{/gist_id}",
"starred_url": "https://api.github.com/users/lephuongbg/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/lephuongbg/subscriptions",
"organizations_url": "https://api.github.com/users/lephuongbg/orgs",
"repos_url": "https://api.github.com/users/lephuongbg/repos",
"events_url": "https://api.github.com/users/lephuongbg/events{/privacy}",
"received_events_url": "https://api.github.com/users/lephuongbg/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"Thanks, nice catch. Merged your patch."
] | 2018-11-29T02:25:40 | 2018-11-29T15:25:06 | 2018-11-29T15:24:54 | NONE | null | Reproducible snippet:
```python
import peewee as p
node = p.ColumnBase()
node.cast('TEXT').cast('JSONB') # Will throw TypeError: 'str' object is not callable
```
I will make a PR soon for this. | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1795/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1795/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1794 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1794/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1794/comments | https://api.github.com/repos/coleifer/peewee/issues/1794/events | https://github.com/coleifer/peewee/issues/1794 | 384,023,723 | MDU6SXNzdWUzODQwMjM3MjM= | 1,794 | get raw sql without parameters | {
"login": "dridk",
"id": 1911063,
"node_id": "MDQ6VXNlcjE5MTEwNjM=",
"avatar_url": "https://avatars.githubusercontent.com/u/1911063?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/dridk",
"html_url": "https://github.com/dridk",
"followers_url": "https://api.github.com/users/dridk/followers",
"following_url": "https://api.github.com/users/dridk/following{/other_user}",
"gists_url": "https://api.github.com/users/dridk/gists{/gist_id}",
"starred_url": "https://api.github.com/users/dridk/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/dridk/subscriptions",
"organizations_url": "https://api.github.com/users/dridk/orgs",
"repos_url": "https://api.github.com/users/dridk/repos",
"events_url": "https://api.github.com/users/dridk/events{/privacy}",
"received_events_url": "https://api.github.com/users/dridk/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"At present Peewee's schema manager does not have support for views.\r\n\r\nJust write out the SQL. In the time you took to type up your issue, and for me to respond, surely you could have typed out the SQL?\r\n\r\nIf you insist, you can implement a custom query component.\r\n\r\nHere's a complete example:\r\n\r\n```python\r\n\r\nfrom peewee import *\r\nfrom peewee import ColumnBase\r\n\r\nclass AsIsValue(ColumnBase):\r\n def __init__(self, value):\r\n self._value = value\r\n super(AsIsValue, self).__init__()\r\n\r\n def __sql__(self, ctx):\r\n if isinstance(self._value, str):\r\n # Ensure strings are quoted.\r\n value = \"'%s'\" % self._value\r\n elif self._value in (True, False):\r\n # Convert boolean to integers.\r\n value = 1 if self._value else 0\r\n elif self._value is None:\r\n value = 'NULL'\r\n return ctx.literal(str(value))\r\n\r\ndb = SqliteDatabase(':memory:')\r\n\r\nclass User(Model):\r\n username = TextField()\r\n is_admin = BooleanField(default=False)\r\n class Meta:\r\n database = db\r\n\r\ndb.create_tables([User])\r\n\r\nfor username, admin in [('huey', True), ('mickey', False), ('zaizee', True)]:\r\n User.create(username=username, is_admin=admin)\r\n\r\nadmin = (User\r\n .select()\r\n .where(User.is_admin == AsIsValue(True))\r\n .order_by(User.username))\r\n\r\nview_sql = 'CREATE VIEW \"user_admin\" AS %s' % admin.sql()[0]\r\ndb.execute_sql(view_sql)\r\n\r\nAdmin = Table('user_admin', ('id', 'username', 'is_admin'))\r\nfor obj in Admin.select().execute(db):\r\n print(obj['username'])\r\n```\r\n\r\nNow...which is easier? Up to you.",
"I did something like this and it works like a charm. I am Not sure it is elegant \r\n\r\n\r\n```python\r\nclass Variant(Model):\r\n\tclass Meta:\r\n\t\tdatabase = db \r\n\r\n\t@classmethod\r\n\tdef create_view(cls,name, where_clause):\r\n\t\tsql = Variant.select().where(where_clause).sql()\r\n\r\n\t\t# replace parameters in raw sql \r\n\t\traw = sql[0]\r\n\t\tparams = sql[1] \r\n\r\n\t\tfor param in params:\r\n # quote params \r\n\t\t\tparam = f\"'{param}'\"\r\n\t\t\traw = raw.replace(\"?\", param, 1) \r\n\r\n\t\tVariant._meta.database.obj.execute_sql(f\"CREATE VIEW {name} AS {raw}\")\r\n\t\t# Create a class dynamically\r\n\t\tclass VariantView(cls):\r\n\t\t\tclass Meta:\r\n\t\t\t\tdb_table = name\r\n\r\n\t\treturn VariantView\r\n\r\nVariant.select().count() // return 590\r\n\r\nMyView = Variant.create_view(\"my_view\", Variant.pos > 432234 ) \r\nMyView.select().count() // return 121 \r\n\r\n\r\n```",
"The use of formatting strings is just vomit, in my opinion...yuck. Whatever works man. I'm glad I'm not maintaining that mess, though."
] | 2018-11-24T21:32:18 | 2018-11-24T23:00:38 | 2018-11-24T22:15:11 | NONE | null | I would like to create a view from a select statement.
Actually, I m trying this :
rawsql = Variant.select().where(Variant.pos > 3000).sql()[0]
db.execute_sql(f"CREATE VIEW test AS {rawsql}" )
Unfortunally, with SQLITE it returns
OperationalError: parameters are not allowed in views
How can I get the raw sql without parameters ?
WHERE value = 3 instead of WHERE value = ? , 3 | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1794/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1794/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1793 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1793/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1793/comments | https://api.github.com/repos/coleifer/peewee/issues/1793/events | https://github.com/coleifer/peewee/issues/1793 | 383,053,357 | MDU6SXNzdWUzODMwNTMzNTc= | 1,793 | Heuristics for determining whether to use python_value is incorrect if uses with CTE having same column with model | {
"login": "lephuongbg",
"id": 1001176,
"node_id": "MDQ6VXNlcjEwMDExNzY=",
"avatar_url": "https://avatars.githubusercontent.com/u/1001176?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/lephuongbg",
"html_url": "https://github.com/lephuongbg",
"followers_url": "https://api.github.com/users/lephuongbg/followers",
"following_url": "https://api.github.com/users/lephuongbg/following{/other_user}",
"gists_url": "https://api.github.com/users/lephuongbg/gists{/gist_id}",
"starred_url": "https://api.github.com/users/lephuongbg/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/lephuongbg/subscriptions",
"organizations_url": "https://api.github.com/users/lephuongbg/orgs",
"repos_url": "https://api.github.com/users/lephuongbg/repos",
"events_url": "https://api.github.com/users/lephuongbg/events{/privacy}",
"received_events_url": "https://api.github.com/users/lephuongbg/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"I believe the relevant changes are here: ecfa98c9f2d5d6b30f238d97928662d909f769e2\r\n\r\nAlthough I would point out that changing the above to \"raw_node\" does not affect the outcome of the query in any case. Change the line and try it for yourself -- the value is still an int.\r\n\r\nThere is no connection, internally, between `tmp.c.id` and either `Products.id` or `Products.id.cast('text')`. Dynamic column references such as `tmp.c.id` bear no relation to any field, and the heuristic simply looks at the column names to try and determine if a dynamic column lines up with a field.\r\n\r\nThe way to handle this correctly is:\r\n\r\n```python\r\nProducts.select(tmp.c.id.coerce(False)).with_cte(tmp).from_(tmp)\r\n```\r\n\r\nAnd in fact, without the change you referred to (`node._coerce` vs `raw_node._coerce`) this logic would not work.\r\n\r\nSo the code is correct, in my opinion. See this test for details: 0d2e81b873c6ac6fe968779c3bf18af06f5a6a47",
"Thanks for clarifying. Though I should say that it might be a breaking change, because it breaks my code after upgrade to newer Peewee. May be a note in CHANGELOG?",
"> because it breaks my code after upgrade to newer Peewee\r\n\r\nAre you sure?",
"Yes. It is one of our company's project and upgrading peewee to master (we also had another problem that was also fixed in master), our CI just broke all over the place that I had a hard time to debug it. Probably because we make use of CTE a lot.\r\n\r\nBut indeed, changing our code to what you suggested works so it's ok for us now. ",
"Gotcha gotcha -- I think I was confused because when testing locally, changing `node` to `raw_node` did not have any effect in the example you provided. However, there are some other reorganizations of that code that may be causing the discrepancies you're seeing.\r\n\r\nAt any rate, using the `.coerce(False)` ought to take care of it. Thanks for your comments and contributions -- it's nice to work w/someone who has a solid understanding of how peewee works."
] | 2018-11-21T10:32:15 | 2018-11-22T15:34:39 | 2018-11-21T16:37:59 | NONE | null | Reproducible snippet:
```python
class Products(Model):
id = IntegerField()
tmp = Products.select(Products.id.cast('text')).cte('tmp', columns=('id',))
# Normally, we will #join with tmp here but use #from_ instead just for demonstration purpose
Products.select(tmp.c.id).with_cte(tmp).from_(tmp)
# => [{'id': 1}] <-- should be string here instead
```
The problem is due to the change of this line:
https://github.com/coleifer/peewee/blob/178bc0155bf569c9245296e90ba5066901e208bc/peewee.py#L6483
```diff
- raw_node._coerce
+ node._coerce
```
| {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1793/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1793/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1792 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1792/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1792/comments | https://api.github.com/repos/coleifer/peewee/issues/1792/events | https://github.com/coleifer/peewee/pull/1792 | 382,929,854 | MDExOlB1bGxSZXF1ZXN0MjMyNTIwNjE2 | 1,792 | In an expression, don't use left hand side's converter if right hand side's is a function | {
"login": "lephuongbg",
"id": 1001176,
"node_id": "MDQ6VXNlcjEwMDExNzY=",
"avatar_url": "https://avatars.githubusercontent.com/u/1001176?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/lephuongbg",
"html_url": "https://github.com/lephuongbg",
"followers_url": "https://api.github.com/users/lephuongbg/followers",
"following_url": "https://api.github.com/users/lephuongbg/following{/other_user}",
"gists_url": "https://api.github.com/users/lephuongbg/gists{/gist_id}",
"starred_url": "https://api.github.com/users/lephuongbg/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/lephuongbg/subscriptions",
"organizations_url": "https://api.github.com/users/lephuongbg/orgs",
"repos_url": "https://api.github.com/users/lephuongbg/repos",
"events_url": "https://api.github.com/users/lephuongbg/events{/privacy}",
"received_events_url": "https://api.github.com/users/lephuongbg/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"I chose to implement this a bit differently -- the result is equivalent for your test-case, however. Rather than checking the rhs inside expression, I thought it made sense to simply not apply a conversion to the arguments of a function at all.\r\n\r\n178bc0155bf569c9245296e90ba5066901e208bc"
] | 2018-11-21T02:34:45 | 2018-11-21T03:00:13 | 2018-11-21T03:00:13 | NONE | null | Should fix #1791 | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1792/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1792/timeline | null | null | false | {
"url": "https://api.github.com/repos/coleifer/peewee/pulls/1792",
"html_url": "https://github.com/coleifer/peewee/pull/1792",
"diff_url": "https://github.com/coleifer/peewee/pull/1792.diff",
"patch_url": "https://github.com/coleifer/peewee/pull/1792.patch",
"merged_at": null
} |
https://api.github.com/repos/coleifer/peewee/issues/1791 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1791/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1791/comments | https://api.github.com/repos/coleifer/peewee/issues/1791/events | https://github.com/coleifer/peewee/issues/1791 | 382,920,940 | MDU6SXNzdWUzODI5MjA5NDA= | 1,791 | Peewee incorrectly uses json.dumps on parameters in edge-case | {
"login": "lephuongbg",
"id": 1001176,
"node_id": "MDQ6VXNlcjEwMDExNzY=",
"avatar_url": "https://avatars.githubusercontent.com/u/1001176?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/lephuongbg",
"html_url": "https://github.com/lephuongbg",
"followers_url": "https://api.github.com/users/lephuongbg/followers",
"following_url": "https://api.github.com/users/lephuongbg/following{/other_user}",
"gists_url": "https://api.github.com/users/lephuongbg/gists{/gist_id}",
"starred_url": "https://api.github.com/users/lephuongbg/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/lephuongbg/subscriptions",
"organizations_url": "https://api.github.com/users/lephuongbg/orgs",
"repos_url": "https://api.github.com/users/lephuongbg/repos",
"events_url": "https://api.github.com/users/lephuongbg/events{/privacy}",
"received_events_url": "https://api.github.com/users/lephuongbg/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"Thanks for this, and for the patch. I chose to implement the fix a bit differently than your suggested fix, but they should be equivalent. The solution I merged is more general, and avoids applying conversion to function arguments in any case.\r\n\r\n178bc0155bf569c9245296e90ba5066901e208bc",
"Thanks. I also did think that this should be put somewhere else better. \r\n\r\nP/S. How could you keep being responsive to every issues all the time like this? (No need to answer, just me admiring you). "
] | 2018-11-21T01:49:45 | 2018-11-21T04:25:59 | 2018-11-21T02:58:52 | NONE | null | Not sure how to make the title better but here is a small reproducible snippet:
```python
import peewee as p
from playhouse.postgres_ext import *
db = PostgresqlExtDatabase(
# The usual config
)
class TestModel(p.Model):
class Meta:
database = db
metadata = BinaryJSONField()
# OK
TestModel.select(p.fn.jsonb_build_object('key', 'value')).execute()
# => SELECT jsonb_build_object('key', 'value') FROM "testmodel" AS "t1"
# NOT OK, see the 'key' is now '"key"', and 'value' is now '"value"' instead
TestModel.select(TestModel.metadata.concat(p.fn.jsonb_build_object('test', 'value'))).execute()
# => SELECT ("t1"."metadata" || jsonb_build_object('"test"', '"value"')) FROM "testmodel" AS "t1"
``` | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1791/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1791/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1790 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1790/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1790/comments | https://api.github.com/repos/coleifer/peewee/issues/1790/events | https://github.com/coleifer/peewee/issues/1790 | 382,488,729 | MDU6SXNzdWUzODI0ODg3Mjk= | 1,790 | How's graphene-peewee going? | {
"login": "yanghg-basefx",
"id": 29534214,
"node_id": "MDQ6VXNlcjI5NTM0MjE0",
"avatar_url": "https://avatars.githubusercontent.com/u/29534214?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/yanghg-basefx",
"html_url": "https://github.com/yanghg-basefx",
"followers_url": "https://api.github.com/users/yanghg-basefx/followers",
"following_url": "https://api.github.com/users/yanghg-basefx/following{/other_user}",
"gists_url": "https://api.github.com/users/yanghg-basefx/gists{/gist_id}",
"starred_url": "https://api.github.com/users/yanghg-basefx/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/yanghg-basefx/subscriptions",
"organizations_url": "https://api.github.com/users/yanghg-basefx/orgs",
"repos_url": "https://api.github.com/users/yanghg-basefx/repos",
"events_url": "https://api.github.com/users/yanghg-basefx/events{/privacy}",
"received_events_url": "https://api.github.com/users/yanghg-basefx/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"I'm not pursuing it, nor am I in a position to recommend an alternative.",
"I ported @insolite’s [graphene-peewee-async](https://github.com/insolite/graphene-peewee-async) to the regular Peewee. Check it out here:\r\n\r\n[graphene-peewee](https://github.com/emperorplatform/graphene-peewee)\r\n\r\nThis is my first major OSS contribution, so please leave feedback if anything can be improved. Also, this is an early release with limited testing. It has not been used in production by me. There may well be bugs."
] | 2018-11-20T03:48:09 | 2020-05-10T21:09:53 | 2018-11-21T03:01:12 | NONE | null | I see [this ticket](https://github.com/graphql-python/graphene/issues/289), and I want to use peewee with graphql, but I didn't find any other info. How's it going? Or I must switch to sqlalchemy to use graphene-sqlalchemy? | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1790/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1790/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1789 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1789/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1789/comments | https://api.github.com/repos/coleifer/peewee/issues/1789/events | https://github.com/coleifer/peewee/issues/1789 | 382,035,232 | MDU6SXNzdWUzODIwMzUyMzI= | 1,789 | logger.debug | {
"login": "adontz",
"id": 829414,
"node_id": "MDQ6VXNlcjgyOTQxNA==",
"avatar_url": "https://avatars.githubusercontent.com/u/829414?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/adontz",
"html_url": "https://github.com/adontz",
"followers_url": "https://api.github.com/users/adontz/followers",
"following_url": "https://api.github.com/users/adontz/following{/other_user}",
"gists_url": "https://api.github.com/users/adontz/gists{/gist_id}",
"starred_url": "https://api.github.com/users/adontz/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/adontz/subscriptions",
"organizations_url": "https://api.github.com/users/adontz/orgs",
"repos_url": "https://api.github.com/users/adontz/repos",
"events_url": "https://api.github.com/users/adontz/events{/privacy}",
"received_events_url": "https://api.github.com/users/adontz/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"The logger statements are intended to log the tuple. Interpolation/parameterization wouldn't work, anyways, as not all databases necessarily use \"%s\" to signify parameters...sqlite uses \"?\" for instance. The idea is that we log both the SQL and the params as a tuple rather than trying to interpolate.",
"I understand that\r\n('SELECT c FROM t WHERE d > ?', [3])\r\nis more preferable than\r\n('SELECT c FROM t WHERE d > 3')\r\nand more correct. I am not saying you can or should interpolate, probably you cannot, or that arguments should not be logged, they should be.\r\n\r\nWhat I am saying is that nobody ever expects LogRecord.msg to be anything but string. All log files are screwed.",
"> What I am saying is that nobody ever expects LogRecord.msg to be anything but string. All log files are screwed.\r\n\r\nYou have to explicitly enable logging for peewee, and even then, at the DEBUG level. If you are trying to log peewee at the debug level, presumably you know what you're doing."
] | 2018-11-19T02:35:51 | 2018-11-19T16:39:08 | 2018-11-19T03:58:13 | NONE | null | I am pretty sure logger.debug is called wrong way all across the code
I have found lines like this
logger.debug((sql, params))
in peewee.py and playhouse/apsw_ext.py, but it really should be
logger.debug(sql, params)
because method signature is
debug(msg, *args, **kwargs)
and one should pass format string and arguments for that format string as separate arguments, not a tuple. You can find an usage example in docs
FORMAT = '%(asctime)-15s %(clientip)s %(user)-8s %(message)s'
logging.basicConfig(format=FORMAT)
d = {'clientip': '192.168.0.1', 'user': 'fbloggs'}
logger = logging.getLogger('tcpserver')
logger.warning('Protocol problem: %s', 'connection reset', extra=d)
Also test_utils.count_queries contains
q.msg[0].startswith('SELECT ')
while it really should be
q.msg.startswith('SELECT ')
Again, you can find in docs that "msg – The event description message, possibly a format string with placeholders for variable data." and not tuple. | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1789/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1789/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1788 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1788/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1788/comments | https://api.github.com/repos/coleifer/peewee/issues/1788/events | https://github.com/coleifer/peewee/issues/1788 | 382,000,012 | MDU6SXNzdWUzODIwMDAwMTI= | 1,788 | [Request] Raise exception on missing parens for field type definitions | {
"login": "ghost",
"id": 10137,
"node_id": "MDQ6VXNlcjEwMTM3",
"avatar_url": "https://avatars.githubusercontent.com/u/10137?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/ghost",
"html_url": "https://github.com/ghost",
"followers_url": "https://api.github.com/users/ghost/followers",
"following_url": "https://api.github.com/users/ghost/following{/other_user}",
"gists_url": "https://api.github.com/users/ghost/gists{/gist_id}",
"starred_url": "https://api.github.com/users/ghost/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/ghost/subscriptions",
"organizations_url": "https://api.github.com/users/ghost/orgs",
"repos_url": "https://api.github.com/users/ghost/repos",
"events_url": "https://api.github.com/users/ghost/events{/privacy}",
"received_events_url": "https://api.github.com/users/ghost/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"Going to pass."
] | 2018-11-18T21:03:15 | 2018-11-19T02:08:55 | 2018-11-19T02:08:55 | NONE | null | When one forgets to add parentheses to a field type definition. e.g.
mtype = IntegerField
instead of
mtype = IntegerField ()
and create_tables executes, tables from the models get built, but columns do not get created for fields w/o parentheses. Exceptions aren't raised either.
It would be nice, if peewee alerted the negligent programmer to his/her mistake(s). | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1788/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1788/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1787 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1787/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1787/comments | https://api.github.com/repos/coleifer/peewee/issues/1787/events | https://github.com/coleifer/peewee/issues/1787 | 381,895,992 | MDU6SXNzdWUzODE4OTU5OTI= | 1,787 | OperationalError when creating table with schema in SQLite | {
"login": "belidzs",
"id": 7085801,
"node_id": "MDQ6VXNlcjcwODU4MDE=",
"avatar_url": "https://avatars.githubusercontent.com/u/7085801?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/belidzs",
"html_url": "https://github.com/belidzs",
"followers_url": "https://api.github.com/users/belidzs/followers",
"following_url": "https://api.github.com/users/belidzs/following{/other_user}",
"gists_url": "https://api.github.com/users/belidzs/gists{/gist_id}",
"starred_url": "https://api.github.com/users/belidzs/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/belidzs/subscriptions",
"organizations_url": "https://api.github.com/users/belidzs/orgs",
"repos_url": "https://api.github.com/users/belidzs/repos",
"events_url": "https://api.github.com/users/belidzs/events{/privacy}",
"received_events_url": "https://api.github.com/users/belidzs/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"Schemas, in SQLite, refer to attached databases. Therefore, to use \"schemas\" in SQLite you will need to attach databases with the given names. This is an advanced usage and probably not what you want, so I recommend avoiding the use of schema with sqlite unless you know what you're doing.",
"Thanks for the quick answer!\r\n\r\nI'm really only using SQLite to simulate my production environment (postgres) as close as possible during testing. In my production database tables are scattered through several schema (however my flask app only uses one). \r\n\r\nIf you say it's not possible to just replace the database driver and use it like that while testing I can live with that but I think it would be nice if the documentation would reflect this limitation. "
] | 2018-11-17T20:00:33 | 2018-11-17T21:07:48 | 2018-11-17T20:58:46 | NONE | null | I have the following model:
```python
db = Proxy()
class BaseModel(Model):
class Meta:
database = db
schema = 'api'
class Koltseg(BaseModel):
id = CharField(primary_key=True, max_length=8)
kotesszam = CharField(max_length=10)
fokonyv = CharField(max_length=50)
kozbeszerzeses = BooleanField()
afas = BooleanField()
osszeg = DecimalField(max_digits=12, decimal_places=2)
```
Normally I use postgres, but during testing I instantiate an in-memory SQLite database and use that. However, when I call `create_tables` from the test fixture I receive an exception complaining there is no database with the name 'api'.
```python
@pytest.fixture
def app():
db = SqliteDatabase(':memory:')
db.bind(MODELS, bind_refs=False, bind_backrefs=False)
db.connect()
db.create_tables(MODELS)
app = create_app(testing=True, test_db=db)
app.config['TESTING'] = True
yield app
db.drop_tables(MODELS)
db.close()
```
And the output:
```
test setup failed
self = <peewee.SqliteDatabase object at 0x0000015CA7DDA9E8>
sql = 'CREATE TABLE IF NOT EXISTS "api"."koltseg" ("id" VARCHAR(8) NOT NULL PRIMARY KEY, "kotesszam" VARCHAR(10) NOT NULL, "...v" VARCHAR(50) NOT NULL, "kozbeszerzeses" INTEGER NOT NULL, "afas" INTEGER NOT NULL, "osszeg" DECIMAL(12, 2) NOT NULL)'
params = [], commit = True
def execute_sql(self, sql, params=None, commit=SENTINEL):
logger.debug((sql, params))
if commit is SENTINEL:
if self.in_transaction():
commit = False
elif self.commit_select:
commit = True
else:
commit = not sql[:6].lower().startswith('select')
with __exception_wrapper__:
cursor = self.cursor(commit)
try:
> cursor.execute(sql, params or ())
E sqlite3.OperationalError: unknown database "api"
```
I'm using peewee 3.7.1 | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1787/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1787/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1786 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1786/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1786/comments | https://api.github.com/repos/coleifer/peewee/issues/1786/events | https://github.com/coleifer/peewee/pull/1786 | 381,861,144 | MDExOlB1bGxSZXF1ZXN0MjMxNzI2NzM5 | 1,786 | Fixed deprecation warning for importing Callable ABC's from collections | {
"login": "AVOstap",
"id": 9307922,
"node_id": "MDQ6VXNlcjkzMDc5MjI=",
"avatar_url": "https://avatars.githubusercontent.com/u/9307922?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/AVOstap",
"html_url": "https://github.com/AVOstap",
"followers_url": "https://api.github.com/users/AVOstap/followers",
"following_url": "https://api.github.com/users/AVOstap/following{/other_user}",
"gists_url": "https://api.github.com/users/AVOstap/gists{/gist_id}",
"starred_url": "https://api.github.com/users/AVOstap/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/AVOstap/subscriptions",
"organizations_url": "https://api.github.com/users/AVOstap/orgs",
"repos_url": "https://api.github.com/users/AVOstap/repos",
"events_url": "https://api.github.com/users/AVOstap/events{/privacy}",
"received_events_url": "https://api.github.com/users/AVOstap/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"Merged equivalent patch."
] | 2018-11-17T13:00:51 | 2018-11-17T16:23:42 | 2018-11-17T16:23:42 | NONE | null | to avoid:
```bash
.../peewee.py:169: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
from collections import Callable
``` | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1786/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1786/timeline | null | null | false | {
"url": "https://api.github.com/repos/coleifer/peewee/pulls/1786",
"html_url": "https://github.com/coleifer/peewee/pull/1786",
"diff_url": "https://github.com/coleifer/peewee/pull/1786.diff",
"patch_url": "https://github.com/coleifer/peewee/pull/1786.patch",
"merged_at": null
} |
https://api.github.com/repos/coleifer/peewee/issues/1785 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1785/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1785/comments | https://api.github.com/repos/coleifer/peewee/issues/1785/events | https://github.com/coleifer/peewee/issues/1785 | 381,704,675 | MDU6SXNzdWUzODE3MDQ2NzU= | 1,785 | model_to_dict fails to process disabled backrefs | {
"login": "adontz",
"id": 829414,
"node_id": "MDQ6VXNlcjgyOTQxNA==",
"avatar_url": "https://avatars.githubusercontent.com/u/829414?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/adontz",
"html_url": "https://github.com/adontz",
"followers_url": "https://api.github.com/users/adontz/followers",
"following_url": "https://api.github.com/users/adontz/following{/other_user}",
"gists_url": "https://api.github.com/users/adontz/gists{/gist_id}",
"starred_url": "https://api.github.com/users/adontz/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/adontz/subscriptions",
"organizations_url": "https://api.github.com/users/adontz/orgs",
"repos_url": "https://api.github.com/users/adontz/repos",
"events_url": "https://api.github.com/users/adontz/events{/privacy}",
"received_events_url": "https://api.github.com/users/adontz/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"Nice, thanks.",
"You response speed in incredible! Thank you!\r\n\r\nCan you please clarify why you have \"not in '!+'\" in one place and \"== '+'\" in another place?\r\nAre not backref='+' and backref='!' the same?",
"Sorry for the lack of documentation on this... \"!\" is retained for backwards-compatibility but should not be used. At some point I will remove that and just use `== '+'`."
] | 2018-11-16T18:06:16 | 2018-11-19T04:17:34 | 2018-11-16T19:55:46 | NONE | null | If there is a model with disabled backref "ForeignKeyField(OtherModel, backref='+')" then model_to_dict fails to convert such model to dict, because model has no '+' attribute
File ".../site-packages/playhouse/shortcuts.py", line 105, in model_to_dict
descriptor = getattr(model_class, foreign_key.backref)
AttributeError: type object 'MyModel' has no attribute '+'
https://github.com/coleifer/peewee/blob/cb6cc1d6bc224070b6deef81dc314fb44c7e8386/playhouse/shortcuts.py#L105
As far as I understand foreign_key.backref should be tested like this
https://github.com/coleifer/peewee/blob/cb6cc1d6bc224070b6deef81dc314fb44c7e8386/peewee.py#L4569
LINK: somehow related to https://github.com/coleifer/peewee/issues/1405 | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1785/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1785/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1784 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1784/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1784/comments | https://api.github.com/repos/coleifer/peewee/issues/1784/events | https://github.com/coleifer/peewee/issues/1784 | 381,166,070 | MDU6SXNzdWUzODExNjYwNzA= | 1,784 | model_to_dict backrefs=True, but exclude_autogenerated, i.e. *_set | {
"login": "patarapolw",
"id": 21255931,
"node_id": "MDQ6VXNlcjIxMjU1OTMx",
"avatar_url": "https://avatars.githubusercontent.com/u/21255931?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/patarapolw",
"html_url": "https://github.com/patarapolw",
"followers_url": "https://api.github.com/users/patarapolw/followers",
"following_url": "https://api.github.com/users/patarapolw/following{/other_user}",
"gists_url": "https://api.github.com/users/patarapolw/gists{/gist_id}",
"starred_url": "https://api.github.com/users/patarapolw/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/patarapolw/subscriptions",
"organizations_url": "https://api.github.com/users/patarapolw/orgs",
"repos_url": "https://api.github.com/users/patarapolw/repos",
"events_url": "https://api.github.com/users/patarapolw/events{/privacy}",
"received_events_url": "https://api.github.com/users/patarapolw/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"There is no \"exclude_autogenerated\" option. You can, however, use the \"exclude\" option to specify the foreign-key of the backref you wish to exclude."
] | 2018-11-15T13:41:54 | 2018-11-15T19:59:36 | 2018-11-15T19:59:35 | NONE | null | Is this possible? Otherwise, I would have to `backrefs=False` altogether, and manually `extra_attrs`. | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1784/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1784/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1783 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1783/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1783/comments | https://api.github.com/repos/coleifer/peewee/issues/1783/events | https://github.com/coleifer/peewee/issues/1783 | 381,144,713 | MDU6SXNzdWUzODExNDQ3MTM= | 1,783 | Documentation on advanced connection management | {
"login": "DaanVanVugt",
"id": 35944,
"node_id": "MDQ6VXNlcjM1OTQ0",
"avatar_url": "https://avatars.githubusercontent.com/u/35944?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/DaanVanVugt",
"html_url": "https://github.com/DaanVanVugt",
"followers_url": "https://api.github.com/users/DaanVanVugt/followers",
"following_url": "https://api.github.com/users/DaanVanVugt/following{/other_user}",
"gists_url": "https://api.github.com/users/DaanVanVugt/gists{/gist_id}",
"starred_url": "https://api.github.com/users/DaanVanVugt/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/DaanVanVugt/subscriptions",
"organizations_url": "https://api.github.com/users/DaanVanVugt/orgs",
"repos_url": "https://api.github.com/users/DaanVanVugt/repos",
"events_url": "https://api.github.com/users/DaanVanVugt/events{/privacy}",
"received_events_url": "https://api.github.com/users/DaanVanVugt/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"That information is outdated and was likely removed when 3.0 was released... I don't see any references to that from within Peewee.\r\n\r\nFor multiprocess, just be sure not to connect until after the fork."
] | 2018-11-15T12:43:12 | 2018-11-15T16:20:14 | 2018-11-15T16:20:14 | NONE | null | Hi,
Thanks for this cool package. I've been trying to work with multiple processes, and find references here and there to http://docs.peewee-orm.com/en/latest/peewee/database.html#advanced-connection-management but can't seem to find this page anymore. Is this not supported anymore?
Thanks,
Daan | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1783/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1783/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1782 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1782/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1782/comments | https://api.github.com/repos/coleifer/peewee/issues/1782/events | https://github.com/coleifer/peewee/issues/1782 | 380,495,779 | MDU6SXNzdWUzODA0OTU3Nzk= | 1,782 | Doc improvement | {
"login": "ghost",
"id": 10137,
"node_id": "MDQ6VXNlcjEwMTM3",
"avatar_url": "https://avatars.githubusercontent.com/u/10137?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/ghost",
"html_url": "https://github.com/ghost",
"followers_url": "https://api.github.com/users/ghost/followers",
"following_url": "https://api.github.com/users/ghost/following{/other_user}",
"gists_url": "https://api.github.com/users/ghost/gists{/gist_id}",
"starred_url": "https://api.github.com/users/ghost/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/ghost/subscriptions",
"organizations_url": "https://api.github.com/users/ghost/orgs",
"repos_url": "https://api.github.com/users/ghost/repos",
"events_url": "https://api.github.com/users/ghost/events{/privacy}",
"received_events_url": "https://api.github.com/users/ghost/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"`fields` is not something you assign, it is inferred from the fields declared on the model. It is a metadata attribute and should be considered read-only."
] | 2018-11-14T01:24:53 | 2018-11-14T03:05:14 | 2018-11-14T03:05:14 | NONE | null | The 'fields' option is missing from the Meta attributes table in the docs (even though it is mentioned immediately above the table) | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1782/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1782/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1781 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1781/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1781/comments | https://api.github.com/repos/coleifer/peewee/issues/1781/events | https://github.com/coleifer/peewee/issues/1781 | 380,175,617 | MDU6SXNzdWUzODAxNzU2MTc= | 1,781 | Aliases, group by and count | {
"login": "ak4nv",
"id": 73960,
"node_id": "MDQ6VXNlcjczOTYw",
"avatar_url": "https://avatars.githubusercontent.com/u/73960?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/ak4nv",
"html_url": "https://github.com/ak4nv",
"followers_url": "https://api.github.com/users/ak4nv/followers",
"following_url": "https://api.github.com/users/ak4nv/following{/other_user}",
"gists_url": "https://api.github.com/users/ak4nv/gists{/gist_id}",
"starred_url": "https://api.github.com/users/ak4nv/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/ak4nv/subscriptions",
"organizations_url": "https://api.github.com/users/ak4nv/orgs",
"repos_url": "https://api.github.com/users/ak4nv/repos",
"events_url": "https://api.github.com/users/ak4nv/events{/privacy}",
"received_events_url": "https://api.github.com/users/ak4nv/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"I see -- good work on finding a workaround.\r\n\r\nLooks to me like a bug. Peewee is being too aggressive about stripping out the selected columns. The logic in the code reads:\r\n\r\n```python\r\n clone = self.order_by().alias('_wrapped')\r\n if clear_limit:\r\n clone._limit = clone._offset = None\r\n try:\r\n if clone._having is None and clone._windows is None and \\\r\n clone._distinct is None and clone._simple_distinct is not True:\r\n clone = clone.select(SQL('1'))\r\n except AttributeError:\r\n pass\r\n return Select([clone], [fn.COUNT(SQL('1'))]).scalar(database)\r\n```\r\n\r\nProbably out to be:\r\n\r\n```python\r\nif clone._having is None and clone._windows is None and \\\r\n clone._distinct is None and clone._simple_distinct is not True and \\\r\n <we're not doing any important joins>:\r\n```\r\n\r\nSince the problem seems to be the removal of the columns which are used for joining subqueries later.",
"Maybe the issue is the group by not lining up actually...",
"I think the patch from cb6cc1d should address the issue, thanks for reporting."
] | 2018-11-13T11:15:04 | 2018-11-13T15:32:32 | 2018-11-13T15:32:32 | NONE | null | Hi @coleifer !
I have a little bit complex query with some joins, aliases, and group by clause (generates a query on the fly). And I found when I try to call a `qs.count()` method I've got an exception:
```
peewee.ProgrammingError: ОШИБКА: столбец "external_source" не существует
LINE 1: ...ROUP BY "t1"."id", "t1"."id", "t1"."external_id", "external_...
^
HINT: Возможно, предполагалась ссылка на столбец "t1.external_source_id".
```
> column "external_source" does not exist. Perhaps you meant to reference the column "t1.external_source_id"
This code generates by peewee:
> `('SELECT "t1"."id", "t1"."external_id", "t2"."name" AS "external_source", "t3"."name" AS "genus", "t1"."isolate_strain_id", "t1"."name", "t1"."ncbi_sequence_id", string_agg("subq"."name", %s) AS "samples", "t4"."name" AS "species", "t1"."synonyms" FROM "hosts" AS "t1" LEFT OUTER JOIN (SELECT "t5"."id", "t5"."name", "t6"."host_id", "t6"."phage_id" FROM "samples" AS "t5" INNER JOIN "source_samples" AS "t6" ON ("t6"."sample_id" = "t5"."id")) AS "subq" ON ("t1"."id" = "subq"."host_id") LEFT OUTER JOIN "taxonomies_names" AS "t3" ON (("t3"."tax_id" = "t1"."genus_id") AND ("t3"."name_class" = %s)) LEFT OUTER JOIN "taxonomies_names" AS "t4" ON (("t4"."tax_id" = "t1"."species_id") AND ("t4"."name_class" = %s)) LEFT OUTER JOIN "simple_entities" AS "t2" ON ("t1"."external_source_id" = "t2"."id") WHERE (text("t1"."id") ILIKE %s) GROUP BY "t1"."id", "t1"."id", "t1"."external_id", "external_source", "genus", "t1"."isolate_strain_id", "t1"."name", "t1"."ncbi_sequence_id", "species", "t1"."synonyms" ORDER BY "t1"."name"', [',', 'scientific name', 'scientific name', '%%'])`
and this code gererates after `qs.count()` calling:
> `('SELECT COUNT(1) FROM (SELECT 1 FROM "hosts" AS "t1" LEFT OUTER JOIN (SELECT "t2"."id", "t2"."name", "t3"."host_id", "t3"."phage_id" FROM "samples" AS "t2" INNER JOIN "source_samples" AS "t3" ON ("t3"."sample_id" = "t2"."id")) AS "subq" ON ("t1"."id" = "subq"."host_id") LEFT OUTER JOIN "taxonomies_names" AS "t4" ON (("t4"."tax_id" = "t1"."genus_id") AND ("t4"."name_class" = ?)) LEFT OUTER JOIN "taxonomies_names" AS "t5" ON (("t5"."tax_id" = "t1"."species_id") AND ("t5"."name_class" = ?)) LEFT OUTER JOIN "simple_entities" AS "t6" ON ("t1"."external_source_id" = "t6"."id") WHERE (text("t1"."id") ILIKE ?) GROUP BY "t1"."id", "t1"."id", "t1"."external_id", "external_source", "genus", "t1"."isolate_strain_id", "t1"."name", "t1"."ncbi_sequence_id", "species", "t1"."synonyms") AS "_wrapped"' , ['scientific name', 'scientific name', '%%'])`
It seems in the `SELECT` section aliases are gone. I wrote my own wrapper for counter
```python
counter = db.Model.select(fn.count('*')).from_(qs).scalar()
```
but maybe it's a bug? | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1781/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1781/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1780 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1780/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1780/comments | https://api.github.com/repos/coleifer/peewee/issues/1780/events | https://github.com/coleifer/peewee/pull/1780 | 378,504,393 | MDExOlB1bGxSZXF1ZXN0MjI5MTk1NTA1 | 1,780 | fix InterfaceError when postgresql connection is closed | {
"login": "velom",
"id": 6709156,
"node_id": "MDQ6VXNlcjY3MDkxNTY=",
"avatar_url": "https://avatars.githubusercontent.com/u/6709156?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/velom",
"html_url": "https://github.com/velom",
"followers_url": "https://api.github.com/users/velom/followers",
"following_url": "https://api.github.com/users/velom/following{/other_user}",
"gists_url": "https://api.github.com/users/velom/gists{/gist_id}",
"starred_url": "https://api.github.com/users/velom/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/velom/subscriptions",
"organizations_url": "https://api.github.com/users/velom/orgs",
"repos_url": "https://api.github.com/users/velom/repos",
"events_url": "https://api.github.com/users/velom/events{/privacy}",
"received_events_url": "https://api.github.com/users/velom/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"I'm unclear on why this patch is necessary. Granted, Peewee could do a lot more introspection to detect whether the connection is closed or not, but this method is intended more to refer to the \"peewee\" connection state rather than the \"driver\" connection state.",
"I'm going to pass on this -- connections dying unexpectedly probably *should* raise an `InterfaceError`.",
"I have described my situation at https://github.com/coleifer/peewee/pull/1779#issuecomment-436895926.\r\nDuring some exceptions, `self._state.conn.closed` became non zero, but `self._state.closed` is still `False`.",
"> I'm going to pass on this -- connections dying unexpectedly probably _should_ raise an `InterfaceError`.\r\n\r\nBy the way, when connection is dying, peewee doesn't switch `self._state.closed` to `True`.\r\nSo every next request will fail here\r\n```python\r\ndef cursor(self, commit=None):\r\n if self.is_closed():\r\n self.connect()\r\n return self._state.conn.cursor()\r\n```\r\nbecause `self.is_closed()` returns `False`, but connection is dead (`self._state.conn.closed != 0`)",
"Correct - it is necessary to implement reconnect logic.",
"do you think, there is no bug in peewee in this case?"
] | 2018-11-07T22:53:24 | 2018-11-08T20:45:50 | 2018-11-08T03:47:49 | NONE | null | when `self._state.closed is False` and `self._state.conn.closed != 0` | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1780/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1780/timeline | null | null | false | {
"url": "https://api.github.com/repos/coleifer/peewee/pulls/1780",
"html_url": "https://github.com/coleifer/peewee/pull/1780",
"diff_url": "https://github.com/coleifer/peewee/pull/1780.diff",
"patch_url": "https://github.com/coleifer/peewee/pull/1780.patch",
"merged_at": null
} |
https://api.github.com/repos/coleifer/peewee/issues/1779 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1779/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1779/comments | https://api.github.com/repos/coleifer/peewee/issues/1779/events | https://github.com/coleifer/peewee/pull/1779 | 378,501,566 | MDExOlB1bGxSZXF1ZXN0MjI5MTkzMzIz | 1,779 | rollback only if connection is not closed | {
"login": "velom",
"id": 6709156,
"node_id": "MDQ6VXNlcjY3MDkxNTY=",
"avatar_url": "https://avatars.githubusercontent.com/u/6709156?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/velom",
"html_url": "https://github.com/velom",
"followers_url": "https://api.github.com/users/velom/followers",
"following_url": "https://api.github.com/users/velom/following{/other_user}",
"gists_url": "https://api.github.com/users/velom/gists{/gist_id}",
"starred_url": "https://api.github.com/users/velom/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/velom/subscriptions",
"organizations_url": "https://api.github.com/users/velom/orgs",
"repos_url": "https://api.github.com/users/velom/repos",
"events_url": "https://api.github.com/users/velom/events{/privacy}",
"received_events_url": "https://api.github.com/users/velom/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"I'm unclear on when this would occur? Take a look at the code to `execute_sql()`:\r\n\r\n```python\r\n def execute_sql(self, sql, params=None, commit=SENTINEL):\r\n logger.debug((sql, params))\r\n if commit is SENTINEL:\r\n if self.in_transaction():\r\n commit = False\r\n elif self.commit_select:\r\n commit = True\r\n else:\r\n commit = not sql[:6].lower().startswith('select')\r\n\r\n with __exception_wrapper__:\r\n cursor = self.cursor(commit)\r\n try:\r\n cursor.execute(sql, params or ())\r\n except Exception:\r\n if self.autorollback and not self.in_transaction():\r\n self.rollback()\r\n raise\r\n else:\r\n if commit and not self.in_transaction():\r\n self.commit()\r\n return cursor\r\n```\r\n\r\nYou can see that we call `cursor = self.cursor(...)`, so what happens in the `cursor` method?\r\n\r\n```python\r\n def cursor(self, commit=None):\r\n if self.is_closed():\r\n self.connect()\r\n return self._state.conn.cursor()\r\n```\r\n\r\nPeewee is already checking if the conn is closed, and if so, it will connect and obtain a DB-API cursor from the driver.\r\n\r\nSo what is going on in your example? Is the connection being closed by the server midway through the query execution or something?\r\n\r\nIn that case, the underlying connection wouldn't appear closed *anyways* since Peewee's determination about whether the conn is closed or not refers only to the internal state within Peewee -- not the actual *liveness* of the connection.\r\n\r\nIt seems like trading one exception for another, and I'm OK with the current behavior.",
"Let's see, what happens in `execute_sql` using `PostgresqlDatabase` with `psycopg2 == 2.7.3`\r\nSection\r\n```python\r\n try:\r\n cursor.execute(sql, params or ())\r\n except Exception:\r\n if self.autorollback and not self.in_transaction():\r\n self.rollback()\r\n raise\r\n else:\r\n if commit and not self.in_transaction():\r\n self.commit()\r\n```\r\nDuring `cursor.execute` there may be an exception like\r\n```\r\nOperationalError: server closed the connection unexpectedly\r\n\tThis probably means the server terminated abnormally\r\n\tbefore or while processing the request.\r\n```\r\nor\r\n```\r\nOperationalError: could not connect to server: Connection timed out\r\n\tIs the server running on host \"XXX\" (1.1.1.1) and accepting\r\n\tTCP/IP connections on port 6432?\r\ncould not make a writable connection to server \"YYY:6432\"\r\ncould not make a writable connection to server \"ZZZ:6432\"\r\n```\r\nThan, psycopg2 connection object became something like this\r\n```\r\n>> self._state.conn.closed\r\n2\r\n```\r\nAfterwards, when we catch this `OperationalError` and call `self.rollback()` psycopg2 driver raises exception `InterfaceError: connection already closed`.\r\nIn this case we will see in logs only `InterfaceError`, original `OperationalError` will be lost. I spent too many debug hours to find this problem.",
"You might consider not using autorollback?",
"Sure, i can reproduce this code in each database request, but autorollback functionality is still broken."
] | 2018-11-07T22:43:55 | 2018-11-08T12:33:45 | 2018-11-08T03:46:55 | NONE | null | this fix prevent next error
```
File "contrib/python/peewee/peewee.py", line 5952, in __iter__
self.execute()
File "contrib/python/peewee/peewee.py", line 1604, in inner
return method(self, database, *args, **kwargs)
File "contrib/python/peewee/peewee.py", line 1675, in execute
return self._execute(database)
File "contrib/python/peewee/peewee.py", line 1826, in _execute
cursor = database.execute(self)
File "contrib/python/peewee/peewee.py", line 2696, in execute
return self.execute_sql(sql, params, commit=commit)
File "contrib/python/peewee/peewee.py", line 2690, in execute_sql
self.commit()
File "contrib/python/peewee/peewee.py", line 2481, in __exit__
reraise(new_type, new_type(*exc_args), traceback)
File "contrib/python/peewee/peewee.py", line 2686, in execute_sql
self.rollback()
File "contrib/python/peewee/peewee.py", line 2805, in rollback
return self._state.conn.rollback()
InterfaceError: connection already closed
``` | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1779/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1779/timeline | null | null | false | {
"url": "https://api.github.com/repos/coleifer/peewee/pulls/1779",
"html_url": "https://github.com/coleifer/peewee/pull/1779",
"diff_url": "https://github.com/coleifer/peewee/pull/1779.diff",
"patch_url": "https://github.com/coleifer/peewee/pull/1779.patch",
"merged_at": null
} |
https://api.github.com/repos/coleifer/peewee/issues/1778 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1778/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1778/comments | https://api.github.com/repos/coleifer/peewee/issues/1778/events | https://github.com/coleifer/peewee/issues/1778 | 378,290,310 | MDU6SXNzdWUzNzgyOTAzMTA= | 1,778 | peewee order_by failed | {
"login": "hanvanos",
"id": 18707141,
"node_id": "MDQ6VXNlcjE4NzA3MTQx",
"avatar_url": "https://avatars.githubusercontent.com/u/18707141?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/hanvanos",
"html_url": "https://github.com/hanvanos",
"followers_url": "https://api.github.com/users/hanvanos/followers",
"following_url": "https://api.github.com/users/hanvanos/following{/other_user}",
"gists_url": "https://api.github.com/users/hanvanos/gists{/gist_id}",
"starred_url": "https://api.github.com/users/hanvanos/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/hanvanos/subscriptions",
"organizations_url": "https://api.github.com/users/hanvanos/orgs",
"repos_url": "https://api.github.com/users/hanvanos/repos",
"events_url": "https://api.github.com/users/hanvanos/events{/privacy}",
"received_events_url": "https://api.github.com/users/hanvanos/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"The update from 2.x to 3.x has a lot more changes than just that:\r\n\r\nhttp://docs.peewee-orm.com/en/latest/peewee/changes.html"
] | 2018-11-07T13:36:27 | 2018-11-07T14:38:25 | 2018-11-07T14:38:25 | NONE | null | I installed a new version of Ubuntu and with that also peewee version3.7.1
Now the order_by meta declaration in the models does not work anymore.
I had to add order_by statements in the queries. | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1778/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1778/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1777 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1777/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1777/comments | https://api.github.com/repos/coleifer/peewee/issues/1777/events | https://github.com/coleifer/peewee/issues/1777 | 378,210,627 | MDU6SXNzdWUzNzgyMTA2Mjc= | 1,777 | RecursionError on large select queries | {
"login": "conqp",
"id": 3766192,
"node_id": "MDQ6VXNlcjM3NjYxOTI=",
"avatar_url": "https://avatars.githubusercontent.com/u/3766192?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/conqp",
"html_url": "https://github.com/conqp",
"followers_url": "https://api.github.com/users/conqp/followers",
"following_url": "https://api.github.com/users/conqp/following{/other_user}",
"gists_url": "https://api.github.com/users/conqp/gists{/gist_id}",
"starred_url": "https://api.github.com/users/conqp/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/conqp/subscriptions",
"organizations_url": "https://api.github.com/users/conqp/orgs",
"repos_url": "https://api.github.com/users/conqp/repos",
"events_url": "https://api.github.com/users/conqp/events{/privacy}",
"received_events_url": "https://api.github.com/users/conqp/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"The recursion error is because you are creating a stack whose length exceeds the stack depth set by the interpreter. Of course you can always manually extend this: https://docs.python.org/3/library/sys.html#sys.setrecursionlimit\r\n\r\nThe problem here:\r\n\r\n```pycon\r\n>>> expression = False\r\n>>> from terminallib import Terminal\r\n>>> for tid, cid in terminals:\r\n... expression |= (Terminal.tid == tid) & (Terminal.customer == cid)\r\n```\r\n\r\nSo you're building up an OR-ed expression that has ~1000 terms (and each of those terms is composed of two expressions). Some SQL databases won't let you do that, so even if you increase your python limits, you'll run into limits from your database.\r\n\r\nMy opinion, in other words, is that you're doing it wrong."
] | 2018-11-07T09:42:13 | 2018-11-07T14:37:47 | 2018-11-07T14:37:47 | CONTRIBUTOR | null | I have a terminals database with ~ 1000 records at the moment.
I use it in python programs programatically using peewee ORM models.
When I try to filter for a huge number of records, I get a recursion error:
```
>>> len(terminals)
576
>>> terminals
[('1', '1000'), <snip>]
>>> expression = False
>>> from terminallib import Terminal
>>> for tid, cid in terminals:
... expression |= (Terminal.tid == tid) & (Terminal.customer == cid)
...
>>> select = Terminal.select().where(expression)
>>> list(select)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 5898, in __iter__
self.execute()
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1589, in inner
return method(self, database, *args, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1660, in execute
return self._execute(database)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1811, in _execute
cursor = database.execute(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 2667, in execute
sql, params = ctx.sql(query).query()
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 2030, in __sql__
ctx.literal(' WHERE ').sql(self._where)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1293, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1283, in __sql__
with ctx(**overrides):
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 531, in __call__
self.state = self.state(**overrides)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 489, in __call__
return State(scope, parentheses, **settings)
RuntimeError: maximum recursion depth exceeded in comparison
```
Any chances, this might get fixed? | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1777/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1777/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1776 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1776/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1776/comments | https://api.github.com/repos/coleifer/peewee/issues/1776/events | https://github.com/coleifer/peewee/pull/1776 | 377,148,281 | MDExOlB1bGxSZXF1ZXN0MjI4MTc0MDg3 | 1,776 | PostgreSQL UPDATE statement with FROM clause with subquery support | {
"login": "nilp0inter",
"id": 1224006,
"node_id": "MDQ6VXNlcjEyMjQwMDY=",
"avatar_url": "https://avatars.githubusercontent.com/u/1224006?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/nilp0inter",
"html_url": "https://github.com/nilp0inter",
"followers_url": "https://api.github.com/users/nilp0inter/followers",
"following_url": "https://api.github.com/users/nilp0inter/following{/other_user}",
"gists_url": "https://api.github.com/users/nilp0inter/gists{/gist_id}",
"starred_url": "https://api.github.com/users/nilp0inter/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/nilp0inter/subscriptions",
"organizations_url": "https://api.github.com/users/nilp0inter/orgs",
"repos_url": "https://api.github.com/users/nilp0inter/repos",
"events_url": "https://api.github.com/users/nilp0inter/events{/privacy}",
"received_events_url": "https://api.github.com/users/nilp0inter/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"I merged a similar patch that is roughly equivalent: 2018e579ac81db5113a26e55ce9078cc80bab446\r\n\r\nI have also removed all references to QualifiedNames in the tests -- the helper is no longer needed as the query-builder handles it correctly now. ",
"Awesome, thanks! "
] | 2018-11-04T12:34:39 | 2018-11-06T18:27:06 | 2018-11-06T17:08:16 | CONTRIBUTOR | null | This is a second try on #1775 , because the request was accepted and then reverted I am opening this.
The changes with master are:
1. I reverted the SET part in the UPDATE test queries.
2. I wrote a helper function to recursively qualify only ColumnBase member of Expressions.
3. I applied this helper to the RHS of the assignments in the SET part of UPDATE queries.
All tests, including the new regressions tests appear to be passing now.
Let me know what you think. | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1776/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1776/timeline | null | null | false | {
"url": "https://api.github.com/repos/coleifer/peewee/pulls/1776",
"html_url": "https://github.com/coleifer/peewee/pull/1776",
"diff_url": "https://github.com/coleifer/peewee/pull/1776.diff",
"patch_url": "https://github.com/coleifer/peewee/pull/1776.patch",
"merged_at": null
} |
https://api.github.com/repos/coleifer/peewee/issues/1775 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1775/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1775/comments | https://api.github.com/repos/coleifer/peewee/issues/1775/events | https://github.com/coleifer/peewee/pull/1775 | 377,050,981 | MDExOlB1bGxSZXF1ZXN0MjI4MTE2MzM4 | 1,775 | Correct format for PostgreSQL UPDATE statement with FROM clause. | {
"login": "nilp0inter",
"id": 1224006,
"node_id": "MDQ6VXNlcjEyMjQwMDY=",
"avatar_url": "https://avatars.githubusercontent.com/u/1224006?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/nilp0inter",
"html_url": "https://github.com/nilp0inter",
"followers_url": "https://api.github.com/users/nilp0inter/followers",
"following_url": "https://api.github.com/users/nilp0inter/following{/other_user}",
"gists_url": "https://api.github.com/users/nilp0inter/gists{/gist_id}",
"starred_url": "https://api.github.com/users/nilp0inter/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/nilp0inter/subscriptions",
"organizations_url": "https://api.github.com/users/nilp0inter/orgs",
"repos_url": "https://api.github.com/users/nilp0inter/repos",
"events_url": "https://api.github.com/users/nilp0inter/events{/privacy}",
"received_events_url": "https://api.github.com/users/nilp0inter/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"The build is passing, which builds against python 2.x/3.x across postgres/mysql/sqlite, so that's fantastic.\r\n\r\nI'm happy to merge this patch and will probably add some regression tests in `tests/regressions.py`. I'm not sure if there are any weird, unintended effects that will crop up from wrapping the WHERE clause in a `scope_normal()` but I hope to clarify that with some additional regression/integration tests.",
"Found one regression, where the right-hand-side of the assignment is a subquery. e.g. to append a user's tweet count to their username:\r\n\r\n```python\r\nsubq = Tweet.select(fn.COUNT(Tweet.id)).where(Tweet.user == User.id)\r\nquery = User.update(username=User.username + '-' + subq)\r\n```",
"I have reverted this patch, as it contains a pretty serious regression (which unfortunately was not covered by a test). You can see the test-cases that illustrate the issue:\r\n\r\nbc4f04886253d81219a5b2e3a7af48bdce22160a\r\n\r\nIf you can find a workaround I'd be happy to merge.\r\n\r\nAlternatively, you can always wrap your own values in `QualifiedNames` before using them on the right-hand-side of the UPDATE?",
"I've merged a patch that implements half of what this patch changed: the \"normal scope\" for the WHERE clause. I've also extended that to apply to the WHERE clause of DELETE queries. However, the QualifiedNames change is still absent due to problems described in my previous comment.",
"Nice catch! I'll give it a go tomorrow using the new regression tests.\r\n\r\nAlso, I am not sure, but I think the RETURNING clause would need `QualifiedNames` too.\r\n\r\nThank you!",
"I'm pretty sure you cannot use qualified names in the returning clause, but feel free to try it out. "
] | 2018-11-03T12:38:32 | 2018-11-03T22:53:15 | 2018-11-03T16:50:31 | CONTRIBUTOR | null | Hi,
I tried to use **UPDATE ... FROM** clause using peewee+PostgreSQL without luck. After seeing #1321 I made this patch to fix it.
I'll explain the problem and my solution.
**The Problem**
Consider the following model:
```python
class Race(Model):
name = CharField()
gold_bonus = IntegerField()
class Meta:
database = db
class Player(Model):
name = CharField()
race = ForeignKeyField(Race, backref='players')
gold = IntegerField(default=0)
class Meta:
database = db
if __name__ == '__main__':
db.connect()
db.create_tables([Race, Player])
r1=Race.create(name='Human', gold_bonus=3)
r2=Race.create(name='Elf', gold_bonus=5)
p1=Player.create(name='player1', race=r1, gold=0)
p2=Player.create(name='player2', race=r2, gold=0)
```
I need to perform a query to increment all players *gold* value by the amount of *gold_bonus* of their race plus one.
So I tried:
```python
>>> Player.update(gold=Race.gold_bonus + Player.gold + 1).from_(Race).where(Player.race==Race.id).execute()
Traceback (most recent call last):
File "/home/nil/.local/share/virtualenvs/miopia-UO75lLMN/lib/python3.6/site-packages/peewee.py", line 2683, in execute_sql
cursor.execute(sql, params or ())
psycopg2.ProgrammingError: column reference "id" is ambiguous
LINE 1: ... + "gold") + 1) FROM "race" AS "t1" WHERE ("race_id" = "id")
^
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/nil/.local/share/virtualenvs/miopia-UO75lLMN/lib/python3.6/site-packages/peewee.py", line 1604, in inner
return method(self, database, *args, **kwargs)
File "/home/nil/.local/share/virtualenvs/miopia-UO75lLMN/lib/python3.6/site-packages/peewee.py", line 1675, in execute
return self._execute(database)
File "/home/nil/.local/share/virtualenvs/miopia-UO75lLMN/lib/python3.6/site-packages/peewee.py", line 2097, in _execute
cursor = database.execute(self)
File "/home/nil/.local/share/virtualenvs/miopia-UO75lLMN/lib/python3.6/site-packages/peewee.py", line 2696, in execute
return self.execute_sql(sql, params, commit=commit)
File "/home/nil/.local/share/virtualenvs/miopia-UO75lLMN/lib/python3.6/site-packages/peewee.py", line 2690, in execute_sql
self.commit()
File "/home/nil/.local/share/virtualenvs/miopia-UO75lLMN/lib/python3.6/site-packages/peewee.py", line 2481, in __exit__
reraise(new_type, new_type(*exc_args), traceback)
File "/home/nil/.local/share/virtualenvs/miopia-UO75lLMN/lib/python3.6/site-packages/peewee.py", line 178, in reraise
raise value.with_traceback(tb)
File "/home/nil/.local/share/virtualenvs/miopia-UO75lLMN/lib/python3.6/site-packages/peewee.py", line 2683, in execute_sql
cursor.execute(sql, params or ())
peewee.ProgrammingError: column reference "id" is ambiguous
LINE 1: ... + "gold") + 1) FROM "race" AS "t1" WHERE ("race_id" = "id")
^
```
The problem is with the generated query:
```sql
UPDATE
"player"
SET
"gold" = (("gold_bonus" + "gold") + 1)
FROM
"race" AS "t1"
WHERE
("race_id" = "id")
```
As you can see, the term **id** is ambiguous as it appears in both *player* and *race* tables.
A correct version of the query should look something like:
```sql
UPDATE
"player"
SET
"gold" = (("t1"."gold_bonus" + "player"."gold") + 1)
FROM
"race" AS "t1"
WHERE
("player"."race_id" = "t1"."id")
```
Note in the *SET* portion of the query, the left hand side of the assignment is not fully-qualified (because you can only assign to fields in the *UPDATE* table) while the right hand side of the assignment is fully-qualified.
**The Patch**
1. I modified the for loop in the \_\_sql\_\_ method of the Update class to use *QualifiedNames()* just for the right hand side of the assignments.
2. In the same method, I modified the part where the **WHERE** is added surrounding it with *ctx.scope_normal*. I don't know if I am using the correct scope, but it yields the desired behavior.
3. I rewrote the part of the tests where static *UPDATE* queries are checked against the implementation, using the new rules for the SET and WHERE part.
I run the test suit against:
- Sqlite: No errors
- Postgres: Some warnings because my installation lacks hstore.
- MySQL: Some errors and failed tests but appears unrelated to this patch.
Please let me know what you think about the patch or any changes/improvements you want me to include.
Cheers!
| {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1775/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1775/timeline | null | null | false | {
"url": "https://api.github.com/repos/coleifer/peewee/pulls/1775",
"html_url": "https://github.com/coleifer/peewee/pull/1775",
"diff_url": "https://github.com/coleifer/peewee/pull/1775.diff",
"patch_url": "https://github.com/coleifer/peewee/pull/1775.patch",
"merged_at": "2018-11-03T16:50:31"
} |
https://api.github.com/repos/coleifer/peewee/issues/1774 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1774/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1774/comments | https://api.github.com/repos/coleifer/peewee/issues/1774/events | https://github.com/coleifer/peewee/issues/1774 | 376,805,687 | MDU6SXNzdWUzNzY4MDU2ODc= | 1,774 | Could/Should BinaryUUID field attempt str -> uuid conversion | {
"login": "Allu2",
"id": 644641,
"node_id": "MDQ6VXNlcjY0NDY0MQ==",
"avatar_url": "https://avatars.githubusercontent.com/u/644641?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/Allu2",
"html_url": "https://github.com/Allu2",
"followers_url": "https://api.github.com/users/Allu2/followers",
"following_url": "https://api.github.com/users/Allu2/following{/other_user}",
"gists_url": "https://api.github.com/users/Allu2/gists{/gist_id}",
"starred_url": "https://api.github.com/users/Allu2/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/Allu2/subscriptions",
"organizations_url": "https://api.github.com/users/Allu2/orgs",
"repos_url": "https://api.github.com/users/Allu2/repos",
"events_url": "https://api.github.com/users/Allu2/events{/privacy}",
"received_events_url": "https://api.github.com/users/Allu2/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"Merged a fix that allows:\r\n\r\n* 32-character hexadecimal string representation\r\n* 16-byte raw binary representation\r\n\r\nThis should solve your problem!"
] | 2018-11-02T13:15:51 | 2018-11-02T14:39:01 | 2018-11-02T14:38:27 | NONE | null | Given model such as:
```python
class Product(Model):
id = BinaryUUIDField(primary_key=True)
```
If I then attempt to create new `Product` from a dict containing:
```python
data_dict = {'id': '74db9954-97c4-4947-941d-42b3fa33be3c'}
```
by something akin to :
```python
product = Product(**data_dict)
product.save()
```
I now see:
```python
File ".../python3.5/site-packages/peewee.py", line 5574, in save
self.insert(**field_dict).execute()
File ".../python3.5/site-packages/peewee.py", line 1574, in inner
return method(self, database, *args, **kwargs)
File ".../python3.5/site-packages/peewee.py", line 1645, in execute
return self._execute(database)
File ".../python3.5/site-packages/peewee.py", line 2288, in _execute
return super(Insert, self)._execute(database)
File ".../python3.5/site-packages/peewee.py", line 2061, in _execute
cursor = self.execute_returning(database)
File ".../python3.5/site-packages/peewee.py", line 2068, in execute_returning
cursor = database.execute(self)
File ".../python3.5/site-packages/playhouse/postgres_ext.py", line 441, in execute
sql, params = ctx.sql(query).query()
File ".../python3.5/site-packages/peewee.py", line 549, in sql
return obj.__sql__(self)
File ".../python3.5/site-packages/peewee.py", line 2263, in __sql__
self._simple_insert(ctx)
File ".../python3.5/site-packages/peewee.py", line 2160, in _simple_insert
return self._generate_insert((self._insert,), ctx)
File ".../python3.5/site-packages/peewee.py", line 2235, in _generate_insert
return ctx.sql(CommaNodeList(all_values))
File ".../python3.5/site-packages/peewee.py", line 549, in sql
return obj.__sql__(self)
File ".../python3.5/site-packages/peewee.py", line 1490, in __sql__
ctx.sql(self.nodes[n_nodes - 1])
File ".../python3.5/site-packages/peewee.py", line 549, in sql
return obj.__sql__(self)
File ".../python3.5/site-packages/peewee.py", line 1488, in __sql__
ctx.sql(self.nodes[i])
File ".../python3.5/site-packages/peewee.py", line 549, in sql
return obj.__sql__(self)
File ".../python3.5/site-packages/peewee.py", line 1202, in __sql__
return ctx.value(self.value, self.converter)
File ".../python3.5/site-packages/peewee.py", line 561, in value
value = converter(value)
File ".../python3.5/site-packages/peewee.py", line 4210, in db_value
raise ValueError('value for binary UUID field must be UUID().')
```
As a workaround I can do:
```python
data_dict['id'] = uuid.UUID(data_dict['id'])
```
Before handing the `data_dict` to model.
This is strip down version of my situation which has bit more complex model.
I'm not sure if I am using peewee incorrectly which leads to this error or if I just assumed incorrectly that `str --> uuid` conversion should happen automagically in situations like this
Peewee version: 3.6.4 | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1774/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1774/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1773 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1773/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1773/comments | https://api.github.com/repos/coleifer/peewee/issues/1773/events | https://github.com/coleifer/peewee/issues/1773 | 376,215,332 | MDU6SXNzdWUzNzYyMTUzMzI= | 1,773 | text field type when using mysql/mariadb database | {
"login": "hegusung",
"id": 7390383,
"node_id": "MDQ6VXNlcjczOTAzODM=",
"avatar_url": "https://avatars.githubusercontent.com/u/7390383?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/hegusung",
"html_url": "https://github.com/hegusung",
"followers_url": "https://api.github.com/users/hegusung/followers",
"following_url": "https://api.github.com/users/hegusung/following{/other_user}",
"gists_url": "https://api.github.com/users/hegusung/gists{/gist_id}",
"starred_url": "https://api.github.com/users/hegusung/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/hegusung/subscriptions",
"organizations_url": "https://api.github.com/users/hegusung/orgs",
"repos_url": "https://api.github.com/users/hegusung/repos",
"events_url": "https://api.github.com/users/hegusung/events{/privacy}",
"received_events_url": "https://api.github.com/users/hegusung/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"Apologies -- the docs are incorrect. Peewee used \"longtext\" up until 3.x, at which point it changed to just plain old \"text\".\r\n\r\nTo have a longtext field:\r\n\r\n```python\r\nclass LongTextField(TextField):\r\n field_type = 'LONGTEXT'\r\n```\r\n\r\nThen just use it as you would a regular `TextField`."
] | 2018-11-01T01:05:29 | 2018-11-01T02:53:47 | 2018-11-01T02:53:47 | NONE | null | Hi,
According to the documentation, TextField should use MySQL longtext column type but it uses the text column type. Is this the desired behavior and the documentation has not been changed? If so, how can I change my code to make sure it uses a longtext and not a text field type?
| {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1773/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1773/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1772 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1772/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1772/comments | https://api.github.com/repos/coleifer/peewee/issues/1772/events | https://github.com/coleifer/peewee/issues/1772 | 375,564,269 | MDU6SXNzdWUzNzU1NjQyNjk= | 1,772 | Add update_or_create() helper method | {
"login": "willyhakim",
"id": 5633805,
"node_id": "MDQ6VXNlcjU2MzM4MDU=",
"avatar_url": "https://avatars.githubusercontent.com/u/5633805?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/willyhakim",
"html_url": "https://github.com/willyhakim",
"followers_url": "https://api.github.com/users/willyhakim/followers",
"following_url": "https://api.github.com/users/willyhakim/following{/other_user}",
"gists_url": "https://api.github.com/users/willyhakim/gists{/gist_id}",
"starred_url": "https://api.github.com/users/willyhakim/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/willyhakim/subscriptions",
"organizations_url": "https://api.github.com/users/willyhakim/orgs",
"repos_url": "https://api.github.com/users/willyhakim/repos",
"events_url": "https://api.github.com/users/willyhakim/events{/privacy}",
"received_events_url": "https://api.github.com/users/willyhakim/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"No. `get_or_create` is a hack and I don't advise anyone to use it under any circumstances. It's vulnerable to race-conditions and weird behavior. Just write the extra 2-3 lines of code and do it right. Wrap it up in a classmethod on the model it pertains to. You can thank me later."
] | 2018-10-30T15:55:36 | 2018-10-30T20:56:12 | 2018-10-30T20:56:12 | NONE | null | get_or_create is amazing! Could we add some more super powers by implementing update_or_create() | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1772/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1772/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1771 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1771/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1771/comments | https://api.github.com/repos/coleifer/peewee/issues/1771/events | https://github.com/coleifer/peewee/issues/1771 | 375,558,485 | MDU6SXNzdWUzNzU1NTg0ODU= | 1,771 | ArrayField of ForeignKeyFields, is it possible? | {
"login": "droserasprout",
"id": 10263434,
"node_id": "MDQ6VXNlcjEwMjYzNDM0",
"avatar_url": "https://avatars.githubusercontent.com/u/10263434?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/droserasprout",
"html_url": "https://github.com/droserasprout",
"followers_url": "https://api.github.com/users/droserasprout/followers",
"following_url": "https://api.github.com/users/droserasprout/following{/other_user}",
"gists_url": "https://api.github.com/users/droserasprout/gists{/gist_id}",
"starred_url": "https://api.github.com/users/droserasprout/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/droserasprout/subscriptions",
"organizations_url": "https://api.github.com/users/droserasprout/orgs",
"repos_url": "https://api.github.com/users/droserasprout/repos",
"events_url": "https://api.github.com/users/droserasprout/events{/privacy}",
"received_events_url": "https://api.github.com/users/droserasprout/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"I wouldn't call that trickery, I'd call it ... well, nevermind.\r\n\r\nJust use an actual junction table. Play to the strengths of your relational database.",
"Sorry to resurrect an old thread, but if anyone (like me) is looking for a similar thing: have a look at the [ManyToManyField](http://docs.peewee-orm.com/en/latest/peewee/api.html#ManyToManyField)"
] | 2018-10-30T15:44:19 | 2022-03-03T22:49:53 | 2018-10-30T20:54:12 | NONE | null | Hi!
I'm working with postgresql and peewee 3.7.1 and trying to initialize model's field as an array of ForeignKeyFields this way:
```python
PreviousTasks = ArrayField(ForeignKeyField, {'model': 'self', 'column_name': 'previous_tasks', 'field': 'ID', 'backref': 'TaskPreviousTasks'})
```
Docs say ArrayField argument field_class gets "a subclass of Field" so this should be possible theoretically. But I'm getting this error:
```python
File "/opt/app/include/models/tickets.py", line 176, in <module>
class Task(ModelBase):
File "/opt/app/include/models/tickets.py", line 191, in Task
PreviousTasks = ArrayField(ForeignKeyField, {'model': 'self', 'column_name': 'previous_tasks', 'field': 'ID', 'backref': 'TaskPreviousTasks'})
File "/usr/local/lib/python3.6/site-packages/playhouse/postgres_ext.py", line 155, in __init__
self.field_type = self.__field.field_type
File "/usr/local/lib/python3.6/site-packages/peewee.py", line 4552, in __getattr__
if attr in self.rel_model._meta.fields:
AttributeError: 'str' object has no attribute '_meta'
```
Is there any way to do this kind of trickery or should I use PreviousTasks as an array of integers and fetch referenced models manually? | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1771/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1771/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1770 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1770/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1770/comments | https://api.github.com/repos/coleifer/peewee/issues/1770/events | https://github.com/coleifer/peewee/issues/1770 | 375,370,895 | MDU6SXNzdWUzNzUzNzA4OTU= | 1,770 | choices are not working! | {
"login": "surajano",
"id": 10608802,
"node_id": "MDQ6VXNlcjEwNjA4ODAy",
"avatar_url": "https://avatars.githubusercontent.com/u/10608802?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/surajano",
"html_url": "https://github.com/surajano",
"followers_url": "https://api.github.com/users/surajano/followers",
"following_url": "https://api.github.com/users/surajano/following{/other_user}",
"gists_url": "https://api.github.com/users/surajano/gists{/gist_id}",
"starred_url": "https://api.github.com/users/surajano/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/surajano/subscriptions",
"organizations_url": "https://api.github.com/users/surajano/orgs",
"repos_url": "https://api.github.com/users/surajano/repos",
"events_url": "https://api.github.com/users/surajano/events{/privacy}",
"received_events_url": "https://api.github.com/users/surajano/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"* http://docs.peewee-orm.com/en/latest/peewee/api.html?highlight=choices#Field\r\n* http://docs.peewee-orm.com/en/latest/peewee/models.html?highlight=choices#some-fields-take-special-parameters\r\n\r\n> Both default and choices could be implemented at the database level as DEFAULT and CHECK CONSTRAINT respectively, but any application change would require a schema change. Because of this, default is implemented purely in python and **choices are not validated but exist for metadata purposes only.**",
"If you want to enforce a particular value that should be done using a CHECK constraint:\r\n\r\n```python\r\nstatus = CharField(constraints=[Check(\"status IN ('S', 'F', 'U')\")])\r\n```"
] | 2018-10-30T08:26:02 | 2018-10-30T14:08:12 | 2018-10-30T14:04:14 | NONE | null | In the following code the choices for Task tables are not working, while creating the instance of Task with status="Success", its not adding the choices value(ie "S") in the task DB table. Its adding the "Success" as it is in the task table.
```
from datetime import datetime
import peewee
db = peewee.SqliteDatabase('peewee_choices.db')
class Task(peewee.Model):
"""
Some Task table Model
"""
TASK_STATUS = (
("S", "Success"),
("F", "Failure"),
("U", "Unknown"),
)
status = peewee.CharField(choices=TASK_STATUS)
timestamp = peewee.DateTimeField(default=datetime.utcnow())
class Meta:
database = db
if __name__ == "__main__":
db.connect()
db.create_tables([Task])
task_events_1 = Task(status="Success")
task_events_1.save()
task_1 = Task.get(status="Success")
print("Task 1 Status : ", task_1.status) # Task 1 Status : Success
task_events_2 = Task(status="S")
task_events_2.save()
task_2 = Task.get(status="S")
print("Task 2 Status : ", task_2.status) # Task 2 Status : S
db.drop_table(Task)
db.close()
```
When we run the above code it will print the following:
Task 1 Status : Success
Task 2 Status : S
| {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1770/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1770/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1769 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1769/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1769/comments | https://api.github.com/repos/coleifer/peewee/issues/1769/events | https://github.com/coleifer/peewee/issues/1769 | 374,408,268 | MDU6SXNzdWUzNzQ0MDgyNjg= | 1,769 | Model field name and the same name for subquery column | {
"login": "ak4nv",
"id": 73960,
"node_id": "MDQ6VXNlcjczOTYw",
"avatar_url": "https://avatars.githubusercontent.com/u/73960?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/ak4nv",
"html_url": "https://github.com/ak4nv",
"followers_url": "https://api.github.com/users/ak4nv/followers",
"following_url": "https://api.github.com/users/ak4nv/following{/other_user}",
"gists_url": "https://api.github.com/users/ak4nv/gists{/gist_id}",
"starred_url": "https://api.github.com/users/ak4nv/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/ak4nv/subscriptions",
"organizations_url": "https://api.github.com/users/ak4nv/orgs",
"repos_url": "https://api.github.com/users/ak4nv/repos",
"events_url": "https://api.github.com/users/ak4nv/events{/privacy}",
"received_events_url": "https://api.github.com/users/ak4nv/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"So peewee sees that you're aliasing a column value to an attribute that is a field on the given model (e.g., you're aliasing a string to the name \"genus\"), which happens to be a foreign-key. Peewee assumes that the value you're storing in the foreign-key field attribute is of the same type as the field would usually store -- an integer ID.\r\n\r\nTo work around this, just use a different alias that doesn't conflict with a field name.\r\n\r\n```python\r\n qs = (Host\r\n .select(Host.id, TaxName.name.alias('genus_name'))\r\n .join(TaxName, on=((Host.genus == TaxName.tax) &\r\n (TaxName.name_class == 'scientific name'))))\r\n\r\n # or\r\n subq = (TaxName\r\n .select(TaxName.tax.alias('id'), TaxName.name)\r\n .where(TaxName.name_class == 'scientific name')).alias('subq')\r\n qs = (Host\r\n .select(Host.id, subq.c.name.alias('genus_name'))\r\n .join(subq, on=(Host.genus == subq.c.id)))\r\n```\r\n\r\nThat's less confusing, anyways, I would think, since your foreign-key attribute is not being overwritten with a string value.",
"@coleifer Yep, I tried to rename alias and it works fine. But I'd like to use the same name. So I used the first variant (without subquery). Thanks!"
] | 2018-10-26T14:26:02 | 2018-10-27T16:46:48 | 2018-10-26T16:27:27 | NONE | null | Hi there!
Three (simplifed) models:
```python
class Tax(db.Model):
id = pw.AutoField(db_column='tax_id')
class TaxName(db.Model):
tax = pw.ForeignKeyField(Tax)
name = pw.CharField(400, null=True)
name_class = pw.CharField(100, null=True)
class Host(db.Model):
id = IDField()
name = pw.CharField(100)
genus = pw.ForeignKeyField(Tax)
```
This code works fine:
```python
qs = (Host
.select(Host.id, TaxName.name.alias('genus'))
.join(TaxName, on=((Host.genus == TaxName.tax) &
(TaxName.name_class == 'scientific name'))))
```
But if I make a subquery:
```python
subq = (TaxName
.select(TaxName.tax.alias('id'), TaxName.name)
.where(TaxName.name_class == 'scientific name')).alias('subq')
qs = (Host
.select(Host.id, subq.c.name.alias('genus'))
.join(subq, on=(Host.genus == subq.c.id)))
```
I get an error:
```
File "/home/ak04nv/.virtualenvs/phd/lib/python3.7/site-packages/peewee.py", line 1706, in __len__
return len(self._cursor_wrapper)
File "/home/ak04nv/.virtualenvs/phd/lib/python3.7/site-packages/peewee.py", line 3696, in __len__
self.fill_cache()
File "/home/ak04nv/.virtualenvs/phd/lib/python3.7/site-packages/peewee.py", line 3737, in fill_cache
iterator.next()
File "/home/ak04nv/.virtualenvs/phd/lib/python3.7/site-packages/peewee.py", line 3793, in next
self.cursor_wrapper.iterate()
File "/home/ak04nv/.virtualenvs/phd/lib/python3.7/site-packages/peewee.py", line 3712, in iterate
result = self.process_row(row)
File "/home/ak04nv/.virtualenvs/phd/lib/python3.7/site-packages/peewee.py", line 6453, in process_row
result[attr] = converters[i](row[i])
File "/home/ak04nv/.virtualenvs/phd/lib/python3.7/site-packages/peewee.py", line 4497, in python_value
return self.rel_field.python_value(value)
File "/home/ak04nv/.virtualenvs/phd/lib/python3.7/site-packages/peewee.py", line 3948, in python_value
return value if value is None else self.adapt(value)
ValueError: invalid literal for int() with base 10: 'Coarctotermes'
```
It seems `peewee` trying to convert `genus` field to an integer. How to fix it?
Any pieces of advice are helpful!
Thanks! | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1769/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1769/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1768 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1768/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1768/comments | https://api.github.com/repos/coleifer/peewee/issues/1768/events | https://github.com/coleifer/peewee/issues/1768 | 372,556,039 | MDU6SXNzdWUzNzI1NTYwMzk= | 1,768 | prefetch not work when joining same model | {
"login": "1xinghuan",
"id": 33982538,
"node_id": "MDQ6VXNlcjMzOTgyNTM4",
"avatar_url": "https://avatars.githubusercontent.com/u/33982538?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/1xinghuan",
"html_url": "https://github.com/1xinghuan",
"followers_url": "https://api.github.com/users/1xinghuan/followers",
"following_url": "https://api.github.com/users/1xinghuan/following{/other_user}",
"gists_url": "https://api.github.com/users/1xinghuan/gists{/gist_id}",
"starred_url": "https://api.github.com/users/1xinghuan/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/1xinghuan/subscriptions",
"organizations_url": "https://api.github.com/users/1xinghuan/orgs",
"repos_url": "https://api.github.com/users/1xinghuan/repos",
"events_url": "https://api.github.com/users/1xinghuan/events{/privacy}",
"received_events_url": "https://api.github.com/users/1xinghuan/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [] | 2018-10-22T14:56:13 | 2018-10-22T16:01:07 | 2018-10-22T16:01:07 | NONE | null | I have some models like this:
```
class Version(BaseModel):
name = CharField()
@property
def sources(self):
return [i.from_version for i in self.sources_connection]
@property
def destinations(self):
return [i.to_version for i in self.destinations_connection]
class VersionRelationship(BaseModel):
from_version = ForeignKeyField(Version, backref='destinations_connection')
to_version = ForeignKeyField(Version, backref='sources_connection')
query = Version.select().where(Version.id > 12700)
# query = query.limit(20)
subquery1 = VersionRelationship.select(VersionRelationship, Version).join(Version, on=VersionRelationship.from_version)
subquery2 = VersionRelationship.select(VersionRelationship, Version).join(Version, on=VersionRelationship.to_version)
prefetch(query, subquery1)
prefetch(query, subquery2)
for q in query:
print q.sources_connection
print q.destinations_connection
print q.sources
print q.destinations
```
When I only prefetch subquery1 and only view sources, it works fine. But doesn't work if I prefetch both and view sources and destinations.
Did I miss something or it's a bug?
| {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1768/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1768/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1767 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1767/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1767/comments | https://api.github.com/repos/coleifer/peewee/issues/1767/events | https://github.com/coleifer/peewee/issues/1767 | 372,545,456 | MDU6SXNzdWUzNzI1NDU0NTY= | 1,767 | prefetch doesn't work when join same model | {
"login": "1xinghuan",
"id": 33982538,
"node_id": "MDQ6VXNlcjMzOTgyNTM4",
"avatar_url": "https://avatars.githubusercontent.com/u/33982538?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/1xinghuan",
"html_url": "https://github.com/1xinghuan",
"followers_url": "https://api.github.com/users/1xinghuan/followers",
"following_url": "https://api.github.com/users/1xinghuan/following{/other_user}",
"gists_url": "https://api.github.com/users/1xinghuan/gists{/gist_id}",
"starred_url": "https://api.github.com/users/1xinghuan/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/1xinghuan/subscriptions",
"organizations_url": "https://api.github.com/users/1xinghuan/orgs",
"repos_url": "https://api.github.com/users/1xinghuan/repos",
"events_url": "https://api.github.com/users/1xinghuan/events{/privacy}",
"received_events_url": "https://api.github.com/users/1xinghuan/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"wrong submit."
] | 2018-10-22T14:30:00 | 2018-10-22T14:59:20 | 2018-10-22T14:58:20 | NONE | null | I have some models like this:
```
class Version(BaseModel):
name = CharField()
@property
def sources(self):
return [i.from_version for i in self.sources_connection]
@property
def destinations(self):
return [i.to_version for i in self.destinations_connection]
class VersionRelationship(BaseModel):
from_version = ForeignKeyField(Version, backref='destinations_connection')
to_version = ForeignKeyField(Version, backref='sources_connection')
query = Version.select().where(Version.id > 12700)
# query = query.limit(20)
subquery1 = VersionRelationship.select(VersionRelationship, Version).join(Version, on=VersionRelationship.from_version)
subquery2 = VersionRelationship.select(VersionRelationship, Version).join(Version, on=VersionRelationship.to_version)
prefetch(query, subquery1)
prefetch(query, subquery2)
for q in query:
print q.sources_connection
print q.destinations_connection
print q.sources
print q.destinations
```
When I only prefetch subquery1 and only view sources, it works fine. But doesn't work if I prefetch both and view sources and destinations.
Did I miss something or it's a bug?
| {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1767/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1767/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1766 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1766/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1766/comments | https://api.github.com/repos/coleifer/peewee/issues/1766/events | https://github.com/coleifer/peewee/issues/1766 | 372,544,044 | MDU6SXNzdWUzNzI1NDQwNDQ= | 1,766 | prefetch not work when join to same model | {
"login": "1xinghuan",
"id": 33982538,
"node_id": "MDQ6VXNlcjMzOTgyNTM4",
"avatar_url": "https://avatars.githubusercontent.com/u/33982538?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/1xinghuan",
"html_url": "https://github.com/1xinghuan",
"followers_url": "https://api.github.com/users/1xinghuan/followers",
"following_url": "https://api.github.com/users/1xinghuan/following{/other_user}",
"gists_url": "https://api.github.com/users/1xinghuan/gists{/gist_id}",
"starred_url": "https://api.github.com/users/1xinghuan/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/1xinghuan/subscriptions",
"organizations_url": "https://api.github.com/users/1xinghuan/orgs",
"repos_url": "https://api.github.com/users/1xinghuan/repos",
"events_url": "https://api.github.com/users/1xinghuan/events{/privacy}",
"received_events_url": "https://api.github.com/users/1xinghuan/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [] | 2018-10-22T14:26:36 | 2018-10-22T14:57:57 | 2018-10-22T14:57:57 | NONE | null | I have some models like this:
```
class Version(BaseModel):
name = CharField()
@property
def sources(self):
return [i.from_version for i in self.sources_connection]
@property
def destinations(self):
return [i.to_version for i in self.destinations_connection]
class VersionRelationship(BaseModel):
from_version = ForeignKeyField(Version, backref='destinations_connection')
to_version = ForeignKeyField(Version, backref='sources_connection')
query = Version.select().where(Version.id > 12700)
# query = query.limit(20)
subquery1 = VersionRelationship.select(VersionRelationship, Version).join(Version, on=VersionRelationship.from_version)
subquery2 = VersionRelationship.select(VersionRelationship, Version).join(Version, on=VersionRelationship.to_version)
prefetch(query, subquery1)
prefetch(query, subquery2)
for q in query:
print q.sources_connection
print q.destinations_connection
print q.sources
print q.destinations
```
When I only prefetch subquery1 and only view sources, it works fine. But doesn't work when prefetch subquery2 and view destinations.
Did I miss something or it's a bug?
| {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1766/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1766/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1765 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1765/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1765/comments | https://api.github.com/repos/coleifer/peewee/issues/1765/events | https://github.com/coleifer/peewee/issues/1765 | 372,194,255 | MDU6SXNzdWUzNzIxOTQyNTU= | 1,765 | query result to python list | {
"login": "michalchrzastek",
"id": 38867528,
"node_id": "MDQ6VXNlcjM4ODY3NTI4",
"avatar_url": "https://avatars.githubusercontent.com/u/38867528?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/michalchrzastek",
"html_url": "https://github.com/michalchrzastek",
"followers_url": "https://api.github.com/users/michalchrzastek/followers",
"following_url": "https://api.github.com/users/michalchrzastek/following{/other_user}",
"gists_url": "https://api.github.com/users/michalchrzastek/gists{/gist_id}",
"starred_url": "https://api.github.com/users/michalchrzastek/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/michalchrzastek/subscriptions",
"organizations_url": "https://api.github.com/users/michalchrzastek/orgs",
"repos_url": "https://api.github.com/users/michalchrzastek/repos",
"events_url": "https://api.github.com/users/michalchrzastek/events{/privacy}",
"received_events_url": "https://api.github.com/users/michalchrzastek/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"It's returning a list of tag instances...you need to:\r\n\r\n```python\r\ndef get_tagsID(self):\r\n tagQ = tag_list.select(tag_list.id)\r\n return [tl.id for tl in tagQ]\r\n```\r\n\r\nAlso python typically prefers lower case w/underscores instead of that camelCase just fyi.",
"By the way, try reading the error message...it seems completely obvious to me at least.",
"Thank you, it works perfectly. No sorry, don't understand the error... "
] | 2018-10-20T09:47:03 | 2018-10-21T07:44:42 | 2018-10-20T22:56:23 | NONE | null | Hello,
I'm trying to return a list with integers (ID column) like so:
`my list = [1,2,3,4,...]`
but get this error, what am I missing?
`TypeError: <modelFinance.tag_list object at 0x759703d0> is not JSON serializable`
my query:
`def get_tagsID(self):
tagQ = tag_list.select(tag_list.id)
return list(tagQ)`
| {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1765/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1765/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1764 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1764/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1764/comments | https://api.github.com/repos/coleifer/peewee/issues/1764/events | https://github.com/coleifer/peewee/issues/1764 | 372,014,868 | MDU6SXNzdWUzNzIwMTQ4Njg= | 1,764 | Diferent results when unit testing one unit test file and unit testing a folder with several files with unit tests | {
"login": "fmors",
"id": 1216208,
"node_id": "MDQ6VXNlcjEyMTYyMDg=",
"avatar_url": "https://avatars.githubusercontent.com/u/1216208?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/fmors",
"html_url": "https://github.com/fmors",
"followers_url": "https://api.github.com/users/fmors/followers",
"following_url": "https://api.github.com/users/fmors/following{/other_user}",
"gists_url": "https://api.github.com/users/fmors/gists{/gist_id}",
"starred_url": "https://api.github.com/users/fmors/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/fmors/subscriptions",
"organizations_url": "https://api.github.com/users/fmors/orgs",
"repos_url": "https://api.github.com/users/fmors/repos",
"events_url": "https://api.github.com/users/fmors/events{/privacy}",
"received_events_url": "https://api.github.com/users/fmors/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"Have you tried with a file-based database? That might provide a clue.\r\n\r\nNo idea but it's certainly not a peewee issue."
] | 2018-10-19T15:48:19 | 2018-10-20T22:54:50 | 2018-10-20T22:54:50 | NONE | null | Here is the context... I have implemented a simple test for a project I'm working on, where this test instantiates a SQLite database on memory, creates a table based on a model and adds some rows to that table, later asserting that my Tornado application GET the rows correctly. The peewee version I'm using is 3.7.0, but with 3.7.1 the behavior is the same. Then I have 2 scenarios:
1. running the functional test with `py.test tests/my_test.py` works perfectly. It injects the rows into the table and, when my Tornado application GET the rows, it will return the rows and the assertion will work.
1. running the functional test with discovery `py.test` does not work. The assertion shows that no row was added to the table, though no error is shown in the process.
This is the model and the test:
```
class BaseModel(Model):
_id = AutoField()
class Meta:
database = Proxy()
@staticmethod
def initialize_db(db):
BaseModel._meta.database.initialize(db)
class Element(BaseModel):
name = CharField()
def initialize_db_and_model():
db = SqliteDatabase(":memory:")
model.BaseModel.initialize_db(db) # model is a package where Element and BaseModel are definedI can give you more details about this issue, but I can't share the entire source-code due to privacy issues.
db.connect()
db.create_tables([model.Element])
return db, model
class TestExperimentHandler(AsyncHTTPTestCase):
I can give you more details about this issue, but I can't share the entire source-code due to privacy issues.
def setUp(self):
self.db, self.model = initialize_db_and_model()
# Populate some data
self.model.Element.create(name='name1')
def get_app(self):
return tornado_application(self.db, self.model)
def test_get_all(self):
response = self.fetch('/element') # return a list of elements from table "element"
elements = json.loads(response.body.decode('utf-8'))
elements_names = list(map(lambda x: x['name'], experiments['_items']))
self.assertEqual(experiments_names, ['name1'])
```
What I could notice, by debugging this application, is that the `Model.create()` method enters the `save()` method when executing the test file individually, but when executing this test file with other tests in a test discovery process, `Model.create()` passes through `save()` without entering there:
```
@classmethod
def create(cls, **query):
inst = cls(**query)
inst.save(force_insert=True)
return inst
```
I have printed the value of `inst` before returning (on `create()`) and added some prints inside `save()`. For the case of starting unit test specifying the file, `inst` equals to 1 before returning, and it enters `save()` method. However, for the case of unit test with discovery, `inst` equals to `None` before returning, and it does not enter `save()` method.
Please let me know if you need any other information. | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1764/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1764/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1763 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1763/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1763/comments | https://api.github.com/repos/coleifer/peewee/issues/1763/events | https://github.com/coleifer/peewee/issues/1763 | 371,782,633 | MDU6SXNzdWUzNzE3ODI2MzM= | 1,763 | Extending JSONField to rename-able keys | {
"login": "patarapolw",
"id": 21255931,
"node_id": "MDQ6VXNlcjIxMjU1OTMx",
"avatar_url": "https://avatars.githubusercontent.com/u/21255931?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/patarapolw",
"html_url": "https://github.com/patarapolw",
"followers_url": "https://api.github.com/users/patarapolw/followers",
"following_url": "https://api.github.com/users/patarapolw/following{/other_user}",
"gists_url": "https://api.github.com/users/patarapolw/gists{/gist_id}",
"starred_url": "https://api.github.com/users/patarapolw/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/patarapolw/subscriptions",
"organizations_url": "https://api.github.com/users/patarapolw/orgs",
"repos_url": "https://api.github.com/users/patarapolw/repos",
"events_url": "https://api.github.com/users/patarapolw/events{/privacy}",
"received_events_url": "https://api.github.com/users/patarapolw/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"I don't understand the code.\r\n\r\nFor sqlite json, I imagine it is possible but not sure off the top of my head."
] | 2018-10-19T02:27:03 | 2018-10-19T13:54:48 | 2018-10-19T13:54:48 | NONE | null | I am thinking of doing something like this:
class JSONValueField(JSONField):
def __init__(json_key, *args, **kwargs):
super().__init__(*args, **kwargs)
self.ref = json_key
def db_value(self, value):
d = dict()
for k, v in value.items():
d[self.ref.from_(k)] = v
return json.dumps(d, ensure_ascii=False)
def python_value(self, value):
d = dict()
for k, v in json.loads(value).items():
d[self.ref.to_(k)] = v
return d
class JSONKeyField(JSONField):
def __init__(*args, **kwargs):
super().__init__(*args, **kwargs)
self.from_ref = dict()
def python_value(self, value):
d = json.loads(value)
for k, v in d.items():
self.from_ref[v] = k
return d
def to_(self, k):
return self[k]
def from_(self, v):
return self.from_ref[v]
# For `self.db_value`, probably fill with k, uuid4(), like
def add(self, k):
self[k] = uuid4()
def remove(self, k):
self.pop(k)
Or Probably, extending ManyToManyField()
BTW, is there an easy way to rename Key in JSON, for every entries? | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1763/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1763/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1762 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1762/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1762/comments | https://api.github.com/repos/coleifer/peewee/issues/1762/events | https://github.com/coleifer/peewee/issues/1762 | 371,646,820 | MDU6SXNzdWUzNzE2NDY4MjA= | 1,762 | Native support for json_group_array() and json_group_object() | {
"login": "brandond",
"id": 370103,
"node_id": "MDQ6VXNlcjM3MDEwMw==",
"avatar_url": "https://avatars.githubusercontent.com/u/370103?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/brandond",
"html_url": "https://github.com/brandond",
"followers_url": "https://api.github.com/users/brandond/followers",
"following_url": "https://api.github.com/users/brandond/following{/other_user}",
"gists_url": "https://api.github.com/users/brandond/gists{/gist_id}",
"starred_url": "https://api.github.com/users/brandond/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/brandond/subscriptions",
"organizations_url": "https://api.github.com/users/brandond/orgs",
"repos_url": "https://api.github.com/users/brandond/repos",
"events_url": "https://api.github.com/users/brandond/events{/privacy}",
"received_events_url": "https://api.github.com/users/brandond/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"FWIW, what I really want in this case is probably something closer to Postgres's `array_agg`, but postgres also has `json_agg`, `json_object_agg`, etc that have their own use case with regards to returning dicts. Also, I'm pretty tied to using sqlite.",
"I've made a patch which somewhat addresses this issue... The following explanation applies to Peewee <= 3.7.1 (up through commit aa2d6f51dc2f50e4):\r\n\r\nBecause these are aggregate functions, they do not easily lend themselves to introspection or a sensible API. We wouldn't make \"group_array\" a method on a `JSONField`, for instance, because it's an aggregate and operates outside the scope of a single column. In your snippet there's nothing to indicate that the returned value is a json-serialized string other than the function name.\r\n\r\nSimilarly, when reading the result value from the db cursor, we don't have an obvious indication that the results are a json-serialized string other than the function name itself. To see how peewee translates the raw data from a cursor into the appropriate data-types, check out `BaseModelCursorWrapper._initialize_columns()`. In fact, depending on the data-type being grouped, its possible that Peewee could attempt (incorrectly) to convert the serialized values. If you change your example to group the Tweet's \"id\" field you will get an error.\r\n\r\n```python\r\nname, messages = (User.select(User.name,\r\n fn.json_group_array(Tweet.id))\r\n .join(Tweet)\r\n .where(User.id == 123)\r\n .scalar(as_tuple=True))\r\n```\r\n\r\nThis will raise an error in peewee <= 3.7.1 -- \"invalid literal for int...\" -- because Peewee uses a heuristic to try and normalize the values returned by aggregates -- which is, it looks at the first parameter in the function call and, if its a Field object, will assume that the result of the aggregate returns a compatible data-type. To avoid this, you need to:\r\n\r\n```python\r\nname, messages = (User.select(User.name,\r\n fn.json_group_array(Tweet.id).coerce(False))\r\n .join(Tweet)\r\n .where(User.id == 123)\r\n .scalar(as_tuple=True))\r\n```\r\n\r\n---------------------\r\n\r\nBack to your question -- because the column you are aggregating into a json value is not necessarily a JSONField (and in fact is probably not) -- there's nothing to indicate to peewee that the value returned by the db is a json string.\r\n\r\nI've made some changes to the internals, however:\r\n\r\n1. When inferring a conversion for a SQL function, ignore TypeError / ValueError that is raised when applying conversion. (e.g., calling int(), which is Tweet.id's conversion function, on the result of a group_concat).\r\n2. Make it possible for a function to explicitly declare a conversion. This makes it possible to specify a custom conversion function on a one-off basis.\r\n\r\nExample of 2, which should address your problem:\r\n\r\n```python\r\nname, messages = (User.select(User.name,\r\n fn.json_group_array(Tweet.message).python_value(json.loads))\r\n .join(Tweet)\r\n .where(User.id == 123)\r\n .scalar(as_tuple=True))\r\n```",
"ecfa98c9f2d5d6b30f238d97928662d909f769e2",
"I was thinking of full extension support like `remove()`, `length()` etc but that works!\r\nhttp://docs.peewee-orm.com/en/latest/peewee/sqlite_ext.html#JSONPath.remove\r\n\r\nFYI, looks like there's an issue with the `remove()` docstring; it claims to use the `json_type` function.",
"Right, but it makes no sense calling json_group_xxx from the context of a json field or path (?)."
] | 2018-10-18T18:06:16 | 2018-10-18T21:59:44 | 2018-10-18T19:55:20 | NONE | null | Ref: https://www.sqlite.org/json1.html#jgrouparray
Right now I'm using these via `fn`, but I have to manually load the resulting JSON. What's the best way to have these come out as native Python lists or dicts?
Example of current usage:
```python
name, messages = (User.select(User.name,
fn.json_group_array(Tweet.message))
.join(Tweet)
.where(User.id == 123)
.scalar(as_tuple=True))
messages = json.loads(messages)
``` | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1762/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1762/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1761 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1761/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1761/comments | https://api.github.com/repos/coleifer/peewee/issues/1761/events | https://github.com/coleifer/peewee/issues/1761 | 371,499,498 | MDU6SXNzdWUzNzE0OTk0OTg= | 1,761 | model_to_dict + ManyToManyField shows abthrough_set instead of bs | {
"login": "patarapolw",
"id": 21255931,
"node_id": "MDQ6VXNlcjIxMjU1OTMx",
"avatar_url": "https://avatars.githubusercontent.com/u/21255931?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/patarapolw",
"html_url": "https://github.com/patarapolw",
"followers_url": "https://api.github.com/users/patarapolw/followers",
"following_url": "https://api.github.com/users/patarapolw/following{/other_user}",
"gists_url": "https://api.github.com/users/patarapolw/gists{/gist_id}",
"starred_url": "https://api.github.com/users/patarapolw/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/patarapolw/subscriptions",
"organizations_url": "https://api.github.com/users/patarapolw/orgs",
"repos_url": "https://api.github.com/users/patarapolw/repos",
"events_url": "https://api.github.com/users/patarapolw/events{/privacy}",
"received_events_url": "https://api.github.com/users/patarapolw/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"You should use `manytomany=True`:\r\n\r\nhttp://docs.peewee-orm.com/en/latest/peewee/playhouse.html#model_to_dict"
] | 2018-10-18T12:10:50 | 2018-10-18T17:17:00 | 2018-10-18T17:16:59 | NONE | null | >>> model_to_dict(db['card'].select()[1], backrefs=True)
{'id': 1520716970993,
'note': {'id': 1520716965129,
'data': {'中文': '我们现在没有钱。',
'Pinyin': 'Wǒmen xiànzài méiyǒu qián.',
'English': "We don't have money now.",
'Notes': '',
'Example Type': '',
'Article Title': 'Negation of "you" with "mei"',
'Grammar Construct': '没 + 有 (+ Obj.)',
'Source URL': 'https://resources.allsetlearning.com/chinese/grammar/ASGPNV3Q'},
'notetagthrough_set': [{'id': 7, 'tag': {'id': 2, 'name': 'Adverbs'}},
{'id': 6, 'tag': {'id': 3, 'name': 'Parts_of_Speech'}},
{'id': 8, 'tag': {'id': 4, 'name': 'A1'}}]},
'deck': {'id': 1496896533573, 'name': 'Chinese Grammar Wiki'},
'template': {'id': 2,
'model': {'id': 1496733135171,
'name': 'Chinese Grammar Wiki',
'css': '.card {\nfont-family: arial;\nfont-size: 30px;\ntext-align: center;\ncolor: black;\nbackground-color: white;\n}\n\n.hanzi {\nfont-family: SimSun;\nfont-size: 28px;\n}\n\n.pinyin {\ncolor: gray;\n}\n\n.translation {\nfont-size: 26px;\n}\n\n.lessonInfoHanzi {\nfont-family: SimSun;\nfont-size: 12px;\n}\n\n.lessonInfo {\nfont-family: arial;\nfont-size: 10px;\n}\n\n.english {\nfont-family: arial;\nfont-size: 20px;\n}\n\n.notes {\nfont-family: arial;\nfont-size: 12px;\ncolor: gray;\n}\n\n.spacer {\nheight: 20px;\n}\n\n.spacerSmall {\nheight: 3px;\n}\n\n.spacerMedium {\nheight: 10px;\n}\n'},
'name': 'Translation',
'question': '<div class="hanzi">{{中文}}</div>',
'answer': '{{FrontSide}}\n<div class="spacer"> </div>\n<div class="english">\n\t<div class="pinyin">{{Pinyin}}</div>\n\t<div class="spacerSmall"> </div>\n\t{{English}}\n\t<div class="spacerMedium"> </div>\n\t<div class="notes">{{Notes}}</div>\n</div>\n\n\n<div class="lessonInfo">\n<div class="spacer"> </div>\n<div>Pattern: <span class="lessonInfoHanzi">{{Grammar Construct}}</span></div>\nArticle: <a href={{Source URL}}>{{Article Title}}</a>\n</div>'},
'srs_level': None,
'next_review': None}
It should be `tags`, not `notetagthrough_set`. | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1761/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1761/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1760 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1760/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1760/comments | https://api.github.com/repos/coleifer/peewee/issues/1760/events | https://github.com/coleifer/peewee/issues/1760 | 371,338,160 | MDU6SXNzdWUzNzEzMzgxNjA= | 1,760 | dont support comment? | {
"login": "mouday",
"id": 24365682,
"node_id": "MDQ6VXNlcjI0MzY1Njgy",
"avatar_url": "https://avatars.githubusercontent.com/u/24365682?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/mouday",
"html_url": "https://github.com/mouday",
"followers_url": "https://api.github.com/users/mouday/followers",
"following_url": "https://api.github.com/users/mouday/following{/other_user}",
"gists_url": "https://api.github.com/users/mouday/gists{/gist_id}",
"starred_url": "https://api.github.com/users/mouday/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/mouday/subscriptions",
"organizations_url": "https://api.github.com/users/mouday/orgs",
"repos_url": "https://api.github.com/users/mouday/repos",
"events_url": "https://api.github.com/users/mouday/events{/privacy}",
"received_events_url": "https://api.github.com/users/mouday/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"Nope, not at present anyways."
] | 2018-10-18T02:37:12 | 2018-10-18T17:15:20 | 2018-10-18T17:15:20 | NONE | null | ```sql
create table table_name (
id int comment "this is field comment"
) comment "this is table comment"
```
peewee not support this help_text? | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1760/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1760/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1759 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1759/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1759/comments | https://api.github.com/repos/coleifer/peewee/issues/1759/events | https://github.com/coleifer/peewee/issues/1759 | 371,030,938 | MDU6SXNzdWUzNzEwMzA5Mzg= | 1,759 | .delete_instance() does not delete ManyToManyField's relationship, causing duplicate key on next create | {
"login": "patarapolw",
"id": 21255931,
"node_id": "MDQ6VXNlcjIxMjU1OTMx",
"avatar_url": "https://avatars.githubusercontent.com/u/21255931?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/patarapolw",
"html_url": "https://github.com/patarapolw",
"followers_url": "https://api.github.com/users/patarapolw/followers",
"following_url": "https://api.github.com/users/patarapolw/following{/other_user}",
"gists_url": "https://api.github.com/users/patarapolw/gists{/gist_id}",
"starred_url": "https://api.github.com/users/patarapolw/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/patarapolw/subscriptions",
"organizations_url": "https://api.github.com/users/patarapolw/orgs",
"repos_url": "https://api.github.com/users/patarapolw/repos",
"events_url": "https://api.github.com/users/patarapolw/events{/privacy}",
"received_events_url": "https://api.github.com/users/patarapolw/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"You have a couple options.\r\n\r\nYou can specify `on_delete='cascade'`, which will automatically delete the DataTag objects when a Data or Tag gets deleted:\r\n\r\n```python\r\ntags = ManyToManyField(Tag, backref='data', on_delete='cascade')\r\n```\r\n\r\nOr, you can specify ``recursive=True`` when calling `delete_instance()`.\r\n\r\n```python\r\ndb_data.delete_instance(recursive=True)\r\n```"
] | 2018-10-17T11:42:24 | 2018-10-17T12:48:48 | 2018-10-17T12:48:48 | NONE | null | class Tag(BaseModel):
name = TextField()
class Data(BaseModel):
tags = ManyToManyField(Tag, backref='data')
DataTag = Data.tags.get_through_model()
db_data = Data.create()
Tag.get_or_create(name='foo')[0].data.add(db_data)
Tag.get_or_create(name='bar')[0].data.add(db_data)
db_data.delete_instance()
db_data = Data.create()
Tag.get_or_create(name='foo')[0].data.add(db_data)
In this case, it will raise an error. Also, the newly created `db_data` persists in the database having tags `['foo', 'bar']`. | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1759/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1759/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1758 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1758/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1758/comments | https://api.github.com/repos/coleifer/peewee/issues/1758/events | https://github.com/coleifer/peewee/issues/1758 | 370,890,346 | MDU6SXNzdWUzNzA4OTAzNDY= | 1,758 | A curious key represent and a little prob | {
"login": "piperck",
"id": 8776176,
"node_id": "MDQ6VXNlcjg3NzYxNzY=",
"avatar_url": "https://avatars.githubusercontent.com/u/8776176?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/piperck",
"html_url": "https://github.com/piperck",
"followers_url": "https://api.github.com/users/piperck/followers",
"following_url": "https://api.github.com/users/piperck/following{/other_user}",
"gists_url": "https://api.github.com/users/piperck/gists{/gist_id}",
"starred_url": "https://api.github.com/users/piperck/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/piperck/subscriptions",
"organizations_url": "https://api.github.com/users/piperck/orgs",
"repos_url": "https://api.github.com/users/piperck/repos",
"events_url": "https://api.github.com/users/piperck/events{/privacy}",
"received_events_url": "https://api.github.com/users/piperck/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"For scalar aggregations, you can:\r\n\r\n```\r\nmax_id, min_id = User.select(fn.MAX(User.id), fn.MIN(User.id)).scalar(as_tuple=True)\r\n```\r\n\r\nIf you want \"User\" instances, then assign an alias to disambiguate the selected columns:\r\n\r\n```\r\nquery = User.select(fn.MAX(User.id).alias('max_id'), fn.MIN(User.id).alias('min_id'))\r\nuser_obj = query[0]\r\nprint(user_obj.max_id, user_obj.min_id)\r\n```"
] | 2018-10-17T04:04:51 | 2018-10-17T12:42:30 | 2018-10-17T12:42:30 | CONTRIBUTOR | null | ```python
In [1]: from apps.models.offline.user import *
In [2]: from peewee import *
In [16]: User.select(fn.MAX(User.id), fn.MIN(User.id)).sql()
Out[16]: ('SELECT MAX(`t1`.`id`), MIN(`t1`.`id`) FROM `user` AS `t1`', [])
In [17]: User.select(fn.MAX(User.id), fn.MIN(User.id)).__dict__
Out[17]:
{'_alias': None,
'_constructor': None,
'_cte_list': None,
'_cursor_wrapper': None,
'_database': <db.init_db.MyRetryDB at 0x5164810>,
'_distinct': None,
'_for_update': None,
'_from_list': [<Model: User>],
'_group_by': None,
'_hash': 7290913799531828381,
'_having': None,
'_is_default': False,
'_join_ctx': <Model: User>,
'_joins': {},
'_limit': None,
'_offset': None,
'_order_by': None,
'_returning': [<peewee.Function at 0x540c450>,
<peewee.Function at 0x540c410>],
'_row_type': None,
'_simple_distinct': None,
'_where': None,
'_windows': None,
'model': <Model: User>}
In [18]: User.select(fn.MAX(User.id), fn.MIN(User.id))[0].__dict__
Out[18]: {'__data__': {}, '__rel__': {}, '_dirty': set(), '`id`)': 2493977}
In [19]: User.select(fn.MAX(User.id), fn.MIN(User.id))[0]
Out[19]: <User: None>
In [20]: User.select(fn.MAX(User.id), fn.MIN(User.id))[0].__dict__
Out[20]: {'__data__': {}, '__rel__': {}, '_dirty': set(), '`id`)': 2493979}
In [21]: User.select(fn.MAX(User.id), fn.MIN(User.id))[0].__dict__['`id`)']
Out[21]: 2493982
In [22]: User.select(fn.MIN(User.id), fn.MAX(User.id))[0].__dict__
Out[22]: {'__data__': {}, '__rel__': {}, '_dirty': set(), '`id`)': 1}
In [24]: User.select(fn.MIN(User.id), fn.MAX(User.uid))[0].__dict__
Out[24]:
{'__data__': {},
'__rel__': {},
'_dirty': set(),
'`id`)': 1,
'`uid`)': u'fffff9fa480038b7e589b7890418b1e3'}
```
Hi:
I have two problem with these code.
First one When I use `User.select(fn.MAX(User.id), fn.MIN(User.id))[0]` why I just get one value `fn.MAX(User.id)` but can not get the `MIN(User.id)` value?
Second one.... when I use .__dict__ to find out why. I have in confused with key `\`id`)\` . Is this deliberate?
Anyone can help me to resolve these problem?
| {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1758/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1758/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1757 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1757/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1757/comments | https://api.github.com/repos/coleifer/peewee/issues/1757/events | https://github.com/coleifer/peewee/issues/1757 | 370,728,878 | MDU6SXNzdWUzNzA3Mjg4Nzg= | 1,757 | peewee.OperationalError: SSL error: bad decrypt | {
"login": "maxcountryman",
"id": 74351,
"node_id": "MDQ6VXNlcjc0MzUx",
"avatar_url": "https://avatars.githubusercontent.com/u/74351?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/maxcountryman",
"html_url": "https://github.com/maxcountryman",
"followers_url": "https://api.github.com/users/maxcountryman/followers",
"following_url": "https://api.github.com/users/maxcountryman/following{/other_user}",
"gists_url": "https://api.github.com/users/maxcountryman/gists{/gist_id}",
"starred_url": "https://api.github.com/users/maxcountryman/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/maxcountryman/subscriptions",
"organizations_url": "https://api.github.com/users/maxcountryman/orgs",
"repos_url": "https://api.github.com/users/maxcountryman/repos",
"events_url": "https://api.github.com/users/maxcountryman/events{/privacy}",
"received_events_url": "https://api.github.com/users/maxcountryman/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"I'm guessing you're opening the database connection before the fork? Try opening the connection after forking. ",
"Actually no, I’m not. The connection is initialized in the function the executor handles. ",
"Can you share a minimal example?",
"If you could please let me know:\r\n\r\n* What database engine / python driver combination are you using?\r\n* What is the output of \"print(db.is_closed())\" when your forked processes are starting up?\r\n* Are you sure it's not possible that some connection state is copied to the child process when forking?"
] | 2018-10-16T17:54:32 | 2018-10-18T17:17:09 | 2018-10-18T17:17:09 | NONE | null | Running into this issue when spawning processes with `concurrent.futures.ProcessPoolExecutor`. | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1757/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1757/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1756 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1756/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1756/comments | https://api.github.com/repos/coleifer/peewee/issues/1756/events | https://github.com/coleifer/peewee/issues/1756 | 370,720,751 | MDU6SXNzdWUzNzA3MjA3NTE= | 1,756 | `object has no attribute` error on join | {
"login": "skatenerd",
"id": 880217,
"node_id": "MDQ6VXNlcjg4MDIxNw==",
"avatar_url": "https://avatars.githubusercontent.com/u/880217?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/skatenerd",
"html_url": "https://github.com/skatenerd",
"followers_url": "https://api.github.com/users/skatenerd/followers",
"following_url": "https://api.github.com/users/skatenerd/following{/other_user}",
"gists_url": "https://api.github.com/users/skatenerd/gists{/gist_id}",
"starred_url": "https://api.github.com/users/skatenerd/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/skatenerd/subscriptions",
"organizations_url": "https://api.github.com/users/skatenerd/orgs",
"repos_url": "https://api.github.com/users/skatenerd/repos",
"events_url": "https://api.github.com/users/skatenerd/events{/privacy}",
"received_events_url": "https://api.github.com/users/skatenerd/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"Is the `joinrow` a `ForeignKeyField`? Which model is the foreign-key on?",
"It's an `IntegerField` on both tables",
"I tried to replicate it, but it seems to be working correctly in my test:\r\n\r\n```python\r\nclass PetType(TestModel):\r\n name = TextField()\r\n flags = IntegerField(default=0)\r\n type_id = IntegerField()\r\n\r\nclass Pet(TestModel):\r\n name = TextField()\r\n pet_type = ForeignKeyField(PetType)\r\n type_id = IntegerField()\r\n\r\nclass TestJoinFalseyRelatedModels1756(ModelTestCase):\r\n requires = [PetType, Pet]\r\n\r\n def test_1756(self):\r\n cat = PetType.create(name='cats', flags=0, type_id=1)\r\n dog = PetType.create(name='dogs', flags=1, type_id=2)\r\n Pet.create(name='huey', pet_type=cat, type_id=1)\r\n Pet.create(name='zaizee', pet_type=cat, type_id=1)\r\n Pet.create(name='mickey', pet_type=dog, type_id=2)\r\n\r\n query = (Pet\r\n .select(Pet.name, PetType.flags)\r\n .join(PetType, on=(Pet.pet_type == PetType.id).alias('kind'))\r\n .order_by(Pet.name))\r\n with self.assertQueryCount(1):\r\n self.assertEqual([(p.name, p.kind.flags) for p in query],\r\n [('huey', 0), ('mickey', 1), ('zaizee', 0)])\r\n\r\n query = (Pet\r\n .select(Pet.name, PetType.flags)\r\n .join(PetType,\r\n on=(Pet.type_id == PetType.type_id).alias('kind'))\r\n .order_by(Pet.name))\r\n with self.assertQueryCount(1):\r\n self.assertEqual([(p.name, p.kind.flags) for p in query],\r\n [('huey', 0), ('mickey', 1), ('zaizee', 0)])\r\n\r\n```",
"Or I suppose I need to change the \"flags=0\" in the test, to \"flags=None\" ?",
"I think to recreate the bug, you need a third table",
"I'm on Peewee 3.7.0 FWIW",
"To clarify, the generated SQL looks like:\r\n`('SELECT \"t1\".\"join_row_id\", \"t2\".\"name\" FROM \"products\" AS \"t1\" INNER JOIN \"departments\" AS \"t2\" ON (\"t2\".\"join_row_id\" = \"t1\".\"join_row_id\") WHERE (\"t1\".\"id\" = %s)', [1])`\r\n\r\n\r\nBefore you invest any time in this, I'll assemble a program that looks like the one you pasted above, just so there's no ambiguity in recreating the issue.",
"I've created a self-contained example here:\r\n\r\nhttps://gist.github.com/skatenerd/45b65a361384869e39ee20069d8ea7d4\r\n\r\nOn my machine, I'm able to make the first print statement in `go()`, but the second crashes with `AttributeError: 'Products' object has no attribute 'department'`",
"To replicate, this is all I needed:\r\n\r\n```python\r\nclass Animal(TestModel):\r\n name = TextField()\r\n flags = IntegerField(null=True)\r\n\r\nclass Pet(TestModel):\r\n name = TextField()\r\n animal = ForeignKeyField(Animal)\r\n\r\ncat = Animal.create(name='cat', flags=0)\r\ndog = Animal.create(name='dog', flags=None)\r\nhuey = Pet.create(name='huey', animal=cat)\r\nmickey = Pet.create(name='mickey', animal=dog)\r\n\r\nbase_query = (Pet\r\n .select(Pet.name, Animal.flags)\r\n .join(Animal)\r\n .order_by(Pet.name))\r\n\r\n# Works, prints \"huey 0\".\r\nfor pet in base_query.where(Pet.name == 'huey'):\r\n print(pet.name, pet.animal.flags)\r\n\r\n# raises DoesNotExist\r\nfor pet in base_query.where(Pet.name == 'mickey'):\r\n print(pet.name, pet.animal.flags)\r\n```\r\n\r\nWhat's going on is a side-effect of the way relational databases use `NULL` to signal missing data. Consider if the Pet.animal foreign-key was nullable and we wanted to list all pets and their animal-type name. If the \"pet\" had an animal relationship, then the name would be displayed. If *no* animal was associated, though, we would see NULL for the animal name.\r\n\r\nThis NULL could signify *either* that the Animal's name was NULL, *or* that the Pet has no related Animal object. In the case that the Pet has no related Animal row, Peewee has a choice between setting the row's \"animal\" object to None, or a \"blank\"/unpopulated Animal instance. Peewee does the latter if-and-only-if all the columns selected from a given model are NULL.\r\n\r\nSo, in your example, I believe it is the fact that `Department.priority` is NULL *and* since it is the only column selected from that table in your query, Peewee cannot tell whether the \"Product\" has a department with a null priority, or if it does not have a department at all (since all the values we selected from the department table are NULL).\r\n\r\nThis is not a bug per-se, but a trade-off between representing missing related objects as \"blank\"/\"empty\" objects versus assuming the related object is `None` if all of the columns we selected from it are also NULL.",
"For your example, you should be able to workaround the \"NULL\" priority by also selecting the Department's primary key, e.g.\r\n\r\n```python\r\nbuilder = (Products\r\n .select(Products.name, Departments.id, Departments.priority)\r\n .join(Departments, on=(Departments.joinrow == Products.joinrow).alias('department'))\r\n .where(Products.id == 1))\r\n```"
] | 2018-10-16T17:33:18 | 2018-10-16T21:03:15 | 2018-10-16T21:00:55 | NONE | null | Suppose I have a many-to-one relationship between `products` and `departments`, where both tables have a `joinrow_id` column. Suppose that we only have one product and its `name` is `"chair"`. The chair is in the only department, whose name is "all products", and whose "priority" is null.
I'm seeing inconsistent behavior between these two queries:
```
builder = Products.select(Products.name,
Departments.name)\
.join(Departments, on=(Departments.joinrow == Products.joinrow).alias('department'))\
.switch(Products)\
.where(Products.id == 1)
```
```
builder = Products.select(Products.name,
Departments.priority)\
.join(Departments, on=(Departments.joinrow == Products.joinrow).alias('department'))\
.switch(Products)\
.where(Products.id == 1)
```
In the first case, seemingly because the `name` field is truthy, I am able to type: `[r for r in builder][0].department.name`
But in the second case, if I try `[r for r in builder][0].department.priority`, the library raises an error:
`Products has no attribute 'department'`.
This is easily remedied. I just have to make sure that, in my select, I include a column from `departments` whose value is always truthy.
I just wanted to bring this behavior to your attention in case you weren't aware. | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1756/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1756/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1755 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1755/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1755/comments | https://api.github.com/repos/coleifer/peewee/issues/1755/events | https://github.com/coleifer/peewee/pull/1755 | 370,350,089 | MDExOlB1bGxSZXF1ZXN0MjIzMDQ4MDUx | 1,755 | [Docs] Update models.rst | {
"login": "MinchinWeb",
"id": 1548809,
"node_id": "MDQ6VXNlcjE1NDg4MDk=",
"avatar_url": "https://avatars.githubusercontent.com/u/1548809?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/MinchinWeb",
"html_url": "https://github.com/MinchinWeb",
"followers_url": "https://api.github.com/users/MinchinWeb/followers",
"following_url": "https://api.github.com/users/MinchinWeb/following{/other_user}",
"gists_url": "https://api.github.com/users/MinchinWeb/gists{/gist_id}",
"starred_url": "https://api.github.com/users/MinchinWeb/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/MinchinWeb/subscriptions",
"organizations_url": "https://api.github.com/users/MinchinWeb/orgs",
"repos_url": "https://api.github.com/users/MinchinWeb/repos",
"events_url": "https://api.github.com/users/MinchinWeb/events{/privacy}",
"received_events_url": "https://api.github.com/users/MinchinWeb/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"replaced by 05a1b468e1b5f885496015e2c749f09eeb7dcd1d\r\n\r\nthanks!",
"Awesome!"
] | 2018-10-15T21:25:02 | 2018-10-15T21:33:50 | 2018-10-15T21:31:26 | NONE | null | datetime import is required to be able to copy and paste this code example | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1755/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1755/timeline | null | null | false | {
"url": "https://api.github.com/repos/coleifer/peewee/pulls/1755",
"html_url": "https://github.com/coleifer/peewee/pull/1755",
"diff_url": "https://github.com/coleifer/peewee/pull/1755.diff",
"patch_url": "https://github.com/coleifer/peewee/pull/1755.patch",
"merged_at": null
} |
https://api.github.com/repos/coleifer/peewee/issues/1754 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1754/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1754/comments | https://api.github.com/repos/coleifer/peewee/issues/1754/events | https://github.com/coleifer/peewee/pull/1754 | 370,341,931 | MDExOlB1bGxSZXF1ZXN0MjIzMDQxNTgy | 1,754 | show how to combine .tuples() and .iterate() | {
"login": "iurly",
"id": 20878097,
"node_id": "MDQ6VXNlcjIwODc4MDk3",
"avatar_url": "https://avatars.githubusercontent.com/u/20878097?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/iurly",
"html_url": "https://github.com/iurly",
"followers_url": "https://api.github.com/users/iurly/followers",
"following_url": "https://api.github.com/users/iurly/following{/other_user}",
"gists_url": "https://api.github.com/users/iurly/gists{/gist_id}",
"starred_url": "https://api.github.com/users/iurly/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/iurly/subscriptions",
"organizations_url": "https://api.github.com/users/iurly/orgs",
"repos_url": "https://api.github.com/users/iurly/repos",
"events_url": "https://api.github.com/users/iurly/events{/privacy}",
"received_events_url": "https://api.github.com/users/iurly/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [] | 2018-10-15T21:00:39 | 2018-10-15T21:11:40 | 2018-10-15T21:11:40 | CONTRIBUTOR | null | From the original description, it sounded like using .tuples(), .dicts() etc would imply .iterate(), which is not the case.
Explicitly state that for maximum performance you might want to do both, and show how you should do it. | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1754/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1754/timeline | null | null | false | {
"url": "https://api.github.com/repos/coleifer/peewee/pulls/1754",
"html_url": "https://github.com/coleifer/peewee/pull/1754",
"diff_url": "https://github.com/coleifer/peewee/pull/1754.diff",
"patch_url": "https://github.com/coleifer/peewee/pull/1754.patch",
"merged_at": "2018-10-15T21:11:40"
} |
https://api.github.com/repos/coleifer/peewee/issues/1753 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1753/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1753/comments | https://api.github.com/repos/coleifer/peewee/issues/1753/events | https://github.com/coleifer/peewee/pull/1753 | 370,322,061 | MDExOlB1bGxSZXF1ZXN0MjIzMDI2MTA2 | 1,753 | Update models.rst | {
"login": "Walicen",
"id": 19557339,
"node_id": "MDQ6VXNlcjE5NTU3MzM5",
"avatar_url": "https://avatars.githubusercontent.com/u/19557339?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/Walicen",
"html_url": "https://github.com/Walicen",
"followers_url": "https://api.github.com/users/Walicen/followers",
"following_url": "https://api.github.com/users/Walicen/following{/other_user}",
"gists_url": "https://api.github.com/users/Walicen/gists{/gist_id}",
"starred_url": "https://api.github.com/users/Walicen/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/Walicen/subscriptions",
"organizations_url": "https://api.github.com/users/Walicen/orgs",
"repos_url": "https://api.github.com/users/Walicen/repos",
"events_url": "https://api.github.com/users/Walicen/events{/privacy}",
"received_events_url": "https://api.github.com/users/Walicen/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"This is incorrect. Fields are non-null by default. So the documentation shows the field parameter with its default value, which is False.",
"OH Sorry!"
] | 2018-10-15T20:03:50 | 2018-10-16T00:33:06 | 2018-10-15T20:32:40 | NONE | null | Allow null values in the fields | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1753/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1753/timeline | null | null | false | {
"url": "https://api.github.com/repos/coleifer/peewee/pulls/1753",
"html_url": "https://github.com/coleifer/peewee/pull/1753",
"diff_url": "https://github.com/coleifer/peewee/pull/1753.diff",
"patch_url": "https://github.com/coleifer/peewee/pull/1753.patch",
"merged_at": null
} |
https://api.github.com/repos/coleifer/peewee/issues/1752 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1752/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1752/comments | https://api.github.com/repos/coleifer/peewee/issues/1752/events | https://github.com/coleifer/peewee/pull/1752 | 369,409,964 | MDExOlB1bGxSZXF1ZXN0MjIyMzU3NjM4 | 1,752 | fix bug group by extend | {
"login": "nhatHero",
"id": 44079687,
"node_id": "MDQ6VXNlcjQ0MDc5Njg3",
"avatar_url": "https://avatars.githubusercontent.com/u/44079687?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/nhatHero",
"html_url": "https://github.com/nhatHero",
"followers_url": "https://api.github.com/users/nhatHero/followers",
"following_url": "https://api.github.com/users/nhatHero/following{/other_user}",
"gists_url": "https://api.github.com/users/nhatHero/gists{/gist_id}",
"starred_url": "https://api.github.com/users/nhatHero/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/nhatHero/subscriptions",
"organizations_url": "https://api.github.com/users/nhatHero/orgs",
"repos_url": "https://api.github.com/users/nhatHero/repos",
"events_url": "https://api.github.com/users/nhatHero/events{/privacy}",
"received_events_url": "https://api.github.com/users/nhatHero/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"Thank you!"
] | 2018-10-12T05:58:27 | 2018-10-12T13:59:06 | 2018-10-12T13:59:02 | NONE | null | I fixed bug group by extend
- Examples:
users table have columns: id and username
Tweet table have contain user_id column. user_id is foreign key of users table
```sql
query = (User
.select(User, fn.COUNT(Tweet.id).alias('tweet_count'))
.join(Tweet, JOIN.LEFT_OUTER)
.group_by_extend(User.id).group_by_extend(User.username))
```
Then I run this query.
- Before I fix bug then result of query :
```sql
SELECT t1.id, t1.username, count(t2.id) as tweet_count
FROM users as t1
LEFT OUTER JOIN tweet as t2 on (t2.user_id = t1.id)
```
- After I fix bug then result of query:
```sql
SELECT t1.id, t1.username, count(t2.id) as tweet_count
FROM users as t1
LEFT OUTER JOIN tweet as t2 on (t2.user_id = t1.id)
GROUP BY t1.id, t1.username # I fixed to add group by
``` | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1752/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1752/timeline | null | null | false | {
"url": "https://api.github.com/repos/coleifer/peewee/pulls/1752",
"html_url": "https://github.com/coleifer/peewee/pull/1752",
"diff_url": "https://github.com/coleifer/peewee/pull/1752.diff",
"patch_url": "https://github.com/coleifer/peewee/pull/1752.patch",
"merged_at": "2018-10-12T13:59:02"
} |
https://api.github.com/repos/coleifer/peewee/issues/1751 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1751/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1751/comments | https://api.github.com/repos/coleifer/peewee/issues/1751/events | https://github.com/coleifer/peewee/issues/1751 | 369,281,758 | MDU6SXNzdWUzNjkyODE3NTg= | 1,751 | elastic-apm intrumentation | {
"login": "claygorman",
"id": 4524500,
"node_id": "MDQ6VXNlcjQ1MjQ1MDA=",
"avatar_url": "https://avatars.githubusercontent.com/u/4524500?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/claygorman",
"html_url": "https://github.com/claygorman",
"followers_url": "https://api.github.com/users/claygorman/followers",
"following_url": "https://api.github.com/users/claygorman/following{/other_user}",
"gists_url": "https://api.github.com/users/claygorman/gists{/gist_id}",
"starred_url": "https://api.github.com/users/claygorman/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/claygorman/subscriptions",
"organizations_url": "https://api.github.com/users/claygorman/orgs",
"repos_url": "https://api.github.com/users/claygorman/repos",
"events_url": "https://api.github.com/users/claygorman/events{/privacy}",
"received_events_url": "https://api.github.com/users/claygorman/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"I'm glad you like the library.\r\n\r\nSorry, never heard of this project."
] | 2018-10-11T19:58:21 | 2018-10-11T20:02:58 | 2018-10-11T20:02:58 | NONE | null | Hey there,
Great library by the way! I use it quite a bit.
I was wondering what your thoughts are on integrating with https://github.com/elastic/apm-agent-python/blob/master/elasticapm/instrumentation/register.py as a built in?
Thanks in advance! | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1751/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1751/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1750 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1750/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1750/comments | https://api.github.com/repos/coleifer/peewee/issues/1750/events | https://github.com/coleifer/peewee/issues/1750 | 368,045,313 | MDU6SXNzdWUzNjgwNDUzMTM= | 1,750 | 1. Cannot create unique index on large text fields 2. Documentation regarding PostGresQL full-text search is unclear | {
"login": "patarapolw",
"id": 21255931,
"node_id": "MDQ6VXNlcjIxMjU1OTMx",
"avatar_url": "https://avatars.githubusercontent.com/u/21255931?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/patarapolw",
"html_url": "https://github.com/patarapolw",
"followers_url": "https://api.github.com/users/patarapolw/followers",
"following_url": "https://api.github.com/users/patarapolw/following{/other_user}",
"gists_url": "https://api.github.com/users/patarapolw/gists{/gist_id}",
"starred_url": "https://api.github.com/users/patarapolw/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/patarapolw/subscriptions",
"organizations_url": "https://api.github.com/users/patarapolw/orgs",
"repos_url": "https://api.github.com/users/patarapolw/repos",
"events_url": "https://api.github.com/users/patarapolw/events{/privacy}",
"received_events_url": "https://api.github.com/users/patarapolw/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"What are you asking? The title of the issue says one thing, but the question within your post seems to be about adding a `unique` constraint to a `TextField`?",
"In the example, \"query\" is a text search query. I'll rename to make it more clear.",
"aa12e607e1b8d073875afbc761c55a2b572271aa",
"> In the example, \"query\" is a text search query. I'll rename to make it more clear.\r\n\r\n'cat & rat' as in `to_tsquery('cat & rat')`? https://www.postgresql.org/docs/9.1/static/functions-textsearch.html\r\n\r\n> What are you asking?\r\n\r\nSorry. I did ask two questions. The first question is well answered, but for the second question, I suppose the answer is \r\n\r\n content = TextField(unique=False)\r\n\r\nThen,\r\n\r\n db.execute_sql('''\r\n CREATE UNIQUE INDEX unique_content_index ON cell (md5(content));\r\n ''')\r\n\r\nBut, how do I do it in pure peewee?",
"You don't need to specify `unique=False` - this is the default behavior.\r\n\r\nTo create an index on an expression like that you have a couple options:\r\n\r\n```python\r\n\r\n# Method one.\r\nCell.add_index(fn.MD5(Cell.content), name='cell_content_hash', unique=True)\r\n\r\n# Method two.\r\nidx = Cell.index(fn.MD5(Cell.content), name='cell_content_hash', unique=True)\r\nCell.add_index(idx)\r\n\r\n# Method three.\r\nclass Cell(Model):\r\n ...\r\n class Meta:\r\n indexes = [\r\n SQL('create unique index cell_content_hash on cell (md5(content))'),\r\n ]\r\n```",
"Thanks for the answer. I would choose Method three.\r\n\r\nAlthough, it would be simpler if I can do something directly in `content = TextField(index=...)` like\r\n\r\n content = TextField(index=fn.MD5, unique=True)\r\n\r\nAs a matter of fact, my problem was originally the content is so large the PostGres cannot unique-ify it."
] | 2018-10-09T05:24:10 | 2018-10-11T00:31:05 | 2018-10-09T12:43:00 | NONE | null | What is `query` in `blog_search(query)` in http://docs.peewee-orm.com/en/latest/peewee/playhouse.html#full-text-search ?
As a matter of fact, I am trying to do:
class Cell(BaseModel):
content = pv.TextField(unique=True)
db_cell = Cell.get_or_none(Cell.content.contains(new_data))
if db_cell is None:
db_cell = Cell.create(
content=new_data
)
My current solution:
class Cell(BaseModel):
content = pv.TextField()
search_content = TSVectorField()
@classmethod
def add_content(cls, content):
return cls.create(
content=content,
search_content=fn.to_tsvector(content)
)
db_cell = Cell.get_or_none(Cell.search_content == fn.to_tsvector(new_data))
if db_cell is None:
db_cell = Cell.add_content(
content=new_data
)
I can't seem to add `unique=True` to content. | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1750/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1750/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1749 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1749/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1749/comments | https://api.github.com/repos/coleifer/peewee/issues/1749/events | https://github.com/coleifer/peewee/issues/1749 | 367,717,962 | MDU6SXNzdWUzNjc3MTc5NjI= | 1,749 | Edit field type with Migrator | {
"login": "bastiendonjon",
"id": 3437591,
"node_id": "MDQ6VXNlcjM0Mzc1OTE=",
"avatar_url": "https://avatars.githubusercontent.com/u/3437591?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/bastiendonjon",
"html_url": "https://github.com/bastiendonjon",
"followers_url": "https://api.github.com/users/bastiendonjon/followers",
"following_url": "https://api.github.com/users/bastiendonjon/following{/other_user}",
"gists_url": "https://api.github.com/users/bastiendonjon/gists{/gist_id}",
"starred_url": "https://api.github.com/users/bastiendonjon/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/bastiendonjon/subscriptions",
"organizations_url": "https://api.github.com/users/bastiendonjon/orgs",
"repos_url": "https://api.github.com/users/bastiendonjon/repos",
"events_url": "https://api.github.com/users/bastiendonjon/events{/privacy}",
"received_events_url": "https://api.github.com/users/bastiendonjon/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"Using peewee's migrating tools you'd need to drop the field and recreate it. Performing column changes requires (sometimes) changing any data present within the column, and that's left to the application rather than being handled by the library."
] | 2018-10-08T10:02:06 | 2018-10-08T17:24:49 | 2018-10-08T17:24:48 | NONE | null | Hello,
It's not possible to change field type with migrator ?
I want edit DateField to DateTimeField
Thanks | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1749/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1749/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1748 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1748/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1748/comments | https://api.github.com/repos/coleifer/peewee/issues/1748/events | https://github.com/coleifer/peewee/issues/1748 | 367,552,583 | MDU6SXNzdWUzNjc1NTI1ODM= | 1,748 | DeprecationWarning Using or importing the ABCs from 'collections' | {
"login": "trim21",
"id": 13553903,
"node_id": "MDQ6VXNlcjEzNTUzOTAz",
"avatar_url": "https://avatars.githubusercontent.com/u/13553903?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/trim21",
"html_url": "https://github.com/trim21",
"followers_url": "https://api.github.com/users/trim21/followers",
"following_url": "https://api.github.com/users/trim21/following{/other_user}",
"gists_url": "https://api.github.com/users/trim21/gists{/gist_id}",
"starred_url": "https://api.github.com/users/trim21/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/trim21/subscriptions",
"organizations_url": "https://api.github.com/users/trim21/orgs",
"repos_url": "https://api.github.com/users/trim21/repos",
"events_url": "https://api.github.com/users/trim21/events{/privacy}",
"received_events_url": "https://api.github.com/users/trim21/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"49ca301f319a6a70d7acd1425b66fa5cbdf75d8e"
] | 2018-10-07T13:01:22 | 2018-10-07T15:50:49 | 2018-10-07T15:50:49 | NONE | null | peewee.py:2256: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
is_dict = isinstance(row, collections.Mapping)
python version 3.7.0
peewee version 3.7.1 | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1748/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1748/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1747 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1747/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1747/comments | https://api.github.com/repos/coleifer/peewee/issues/1747/events | https://github.com/coleifer/peewee/issues/1747 | 366,937,366 | MDU6SXNzdWUzNjY5MzczNjY= | 1,747 | TimestampField appears to strip milliseconds | {
"login": "tbaxter-18f",
"id": 32077682,
"node_id": "MDQ6VXNlcjMyMDc3Njgy",
"avatar_url": "https://avatars.githubusercontent.com/u/32077682?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/tbaxter-18f",
"html_url": "https://github.com/tbaxter-18f",
"followers_url": "https://api.github.com/users/tbaxter-18f/followers",
"following_url": "https://api.github.com/users/tbaxter-18f/following{/other_user}",
"gists_url": "https://api.github.com/users/tbaxter-18f/gists{/gist_id}",
"starred_url": "https://api.github.com/users/tbaxter-18f/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/tbaxter-18f/subscriptions",
"organizations_url": "https://api.github.com/users/tbaxter-18f/orgs",
"repos_url": "https://api.github.com/users/tbaxter-18f/repos",
"events_url": "https://api.github.com/users/tbaxter-18f/events{/privacy}",
"received_events_url": "https://api.github.com/users/tbaxter-18f/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"Well, here's the thing. Peewee's `TimestampField` is designed to work with python `datetime` objects, which is typically what you want in your application code -- it just uses an integer timestamp for storage. That being said, you still *can* specify integer / floating-point timestamps. For sub-second resolutions you will just need to also specify the desired resolution when instantiating the field, expressed as a power-of-10. This works because behind-the-scenes Peewee just multiplies the timestamp by a power-of-10 to obtain an integer.\r\n\r\n```python\r\nclass Event(Model):\r\n timestamp = TimestampField(resolution=1e6) # microseconds.\r\n data = TextField()\r\n\r\n# We can specify an integer or floating-point timestamp -- peewee will do the right thing:\r\nts = 1500000000.123456 # 2017-07-13 21:40:00.123456\r\nEvent.create(timestamp=ts, data='event-1')\r\n\r\n# Or we can just use a datetime object:\r\ndt = datetime.datetime(2018, 1, 2, 3, 4, 5, 6789)\r\nEvent.create(timestamp=dt, data='event-2')\r\n\r\n# Peewee converts to datetimes when reading from the db:\r\nfor event in Event.select():\r\n print(event.data, ':', event.timestamp)\r\n\r\n# Prints:\r\n# event-1 : 2017-07-13 21:40:00.123456\r\n# event-2 : 2018-01-02 03:04:05.006789\r\n```"
] | 2018-10-04T19:31:40 | 2018-10-04T20:04:24 | 2018-10-04T20:04:24 | NONE | null | given a timestamp like 1419440770.000058 when I create the object, the timestamp appears to be stored as 1419440770, with no milliseconds present any longer. | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1747/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1747/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1746 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1746/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1746/comments | https://api.github.com/repos/coleifer/peewee/issues/1746/events | https://github.com/coleifer/peewee/issues/1746 | 366,161,434 | MDU6SXNzdWUzNjYxNjE0MzQ= | 1,746 | Consistency between `Dataset.insert` / `Dataset.update` and `Model.insert` / `Model.update` | {
"login": "patarapolw",
"id": 21255931,
"node_id": "MDQ6VXNlcjIxMjU1OTMx",
"avatar_url": "https://avatars.githubusercontent.com/u/21255931?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/patarapolw",
"html_url": "https://github.com/patarapolw",
"followers_url": "https://api.github.com/users/patarapolw/followers",
"following_url": "https://api.github.com/users/patarapolw/following{/other_user}",
"gists_url": "https://api.github.com/users/patarapolw/gists{/gist_id}",
"starred_url": "https://api.github.com/users/patarapolw/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/patarapolw/subscriptions",
"organizations_url": "https://api.github.com/users/patarapolw/orgs",
"repos_url": "https://api.github.com/users/patarapolw/repos",
"events_url": "https://api.github.com/users/patarapolw/events{/privacy}",
"received_events_url": "https://api.github.com/users/patarapolw/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"@patarapolw -- I think you may misunderstand the point of `dataset`. The `dataset` library is strictly a convenience API -- although it exposes a lot of functionality, it is not intended to implement all the features you might expect to find using standard Peewee APIs.\r\n\r\nAlso, your upsert implementation is wide open to race conditions. Peewee has sophisticated support for upsert with SQLite 3.24.0 and newer. For older versions, you probably should use an exclusive lock:\r\n\r\n```python\r\nwith db.atomic('exclusive'):\r\n ...\r\n```",
"How should I upsert, then?\r\n\r\nI have just googled and found these two \r\n- https://github.com/coleifer/peewee/issues/1307\r\n- https://stackoverflow.com/questions/33485312/insert-or-update-a-peewee-record-in-python\r\n\r\nMaybe,\r\n\r\n @classmethod\r\n def upsert(cls, columns, **kwargs):\r\n try:\r\n cls.insert(**kwargs).execute()\r\n except pv.IntegrityError:\r\n query = (getattr(cls, columns[0]) == kwargs.get(columns[0]))\r\n for col in columns[1:]:\r\n query = query & (getattr(cls, col) == kwargs.get(col))\r\n\r\n cls.update(kwargs).where(query).execute()\r\n\r\nThis one works, but race condition? I don't know.",
"The docs are a good place to look:\r\n\r\nhttp://docs.peewee-orm.com/en/latest/peewee/querying.html#upsert",
"\trowid = (User\r\n\t .insert(username='huey', last_login=now, login_count=1)\r\n\t .on_conflict(\r\n\t conflict_target=[User.username], # Which constraint?\r\n\t preserve=[User.last_login], # Use the value we would have inserted.\r\n\t update={User.login_count: User.login_count + 1})\r\n\t .execute())\r\n\r\nI can't use preserve or update clause in SQLite 3.22. Replace everything without preserve (`User.replace()`) raises:\r\n\r\n peewee.IntegrityError: NOT NULL constraint failed: patient.full_name\r\n\r\nAnd I can't figure out a way to update Python3-SQLite on Mac. (I successfully updated the system one, though.)",
"> Peewee has sophisticated support for upsert with SQLite 3.24.0 and newer. For older versions, you probably should use an exclusive lock..."
] | 2018-10-03T03:30:56 | 2018-10-04T03:40:22 | 2018-10-03T03:45:21 | NONE | null | It's not consistent in that making transferring from Dataset to SqliteExtDatabase harder.
Furthermore, there is no upsert function. I have to create my own.
class BaseModel(pv.Model):
@classmethod
def upsert(cls, columns, **kwargs):
query = (getattr(cls, columns[0]) == kwargs.get(columns[0]))
for col in columns[1:]:
query = query & (getattr(cls, col) == kwargs.get(col))
records = set()
for record in cls.select().where(query):
for k, v in kwargs.items():
setattr(record, k, v)
record.save()
records.add(record)
if len(records) == 0:
cls.create(**kwargs)
| {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1746/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1746/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1745 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1745/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1745/comments | https://api.github.com/repos/coleifer/peewee/issues/1745/events | https://github.com/coleifer/peewee/issues/1745 | 365,537,810 | MDU6SXNzdWUzNjU1Mzc4MTA= | 1,745 | FTSModel associated to table with non-integer primary key | {
"login": "jbriales",
"id": 6850478,
"node_id": "MDQ6VXNlcjY4NTA0Nzg=",
"avatar_url": "https://avatars.githubusercontent.com/u/6850478?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/jbriales",
"html_url": "https://github.com/jbriales",
"followers_url": "https://api.github.com/users/jbriales/followers",
"following_url": "https://api.github.com/users/jbriales/following{/other_user}",
"gists_url": "https://api.github.com/users/jbriales/gists{/gist_id}",
"starred_url": "https://api.github.com/users/jbriales/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/jbriales/subscriptions",
"organizations_url": "https://api.github.com/users/jbriales/orgs",
"repos_url": "https://api.github.com/users/jbriales/repos",
"events_url": "https://api.github.com/users/jbriales/events{/privacy}",
"received_events_url": "https://api.github.com/users/jbriales/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"There's no good reason to use a non-integer primary key in SQLite (unless you're also using `WITHOUT ROWID` in your table). SQLite's btree uses a 64-bit integer internally to store the rowid of a given row. If you use an integer primary key, then it will utilize that internal rowid automatically.\r\n\r\nIf you want to use a hash, just store the hash in a secondary column with a unique index.\r\n\r\n> The Notes table uses a non-integer primary key with hash text ids.\r\n\r\nI'm not sure what \"hash text ids\" means. You mean a md5 or something? An md5 is 16-bytes...you could maybe 8 bytes of the hash and treat them as a 64-bit integer... `struct.unpack('q', checksum.digest()[:8])` ('q' for signed, 'Q' for unsigned).\r\n\r\nLastly, you could create an additional column on your FTSEntry model which stores the hash, but note that this is a TERRIBLE idea and will require a FULL TABLE SCAN every single time.",
"Also it's silly to store the hash as `TEXT`...just store the bytes in a `BLOB` field.",
"Thanks for the detailed answer.\r\nAs I said, this is a third party database, so unfortunately I cannot modify those poor design decisions without breaking the depending task.\r\n\r\nUnder the constraints above (that is Note has primary field `id = TextField(null=True, primary_key=True)`), is it possible store the hashes in the virtual table (which I'm creating from scratch) like `uid = SearchField()`, then do the search on the virtual table, sth like\r\n```\r\nNoteIndex\r\n .select()\r\n .where(NoteIndex.match(search_string))\r\n```\r\nand join the corresponding rows of the main table via a join where Note.id == NoteIndex.uid? Would that keep efficient?",
"That's what I was saying in the last paragraph:\r\n\r\n> Lastly, you could create an additional column on your FTSEntry model which stores the hash, but note that this is a TERRIBLE idea and will require a FULL TABLE SCAN every single time.\r\n\r\nIn the fts virtual table it is only efficient to join on the rowid/docid field of the virtual table. All other fields incur a full scan so you get O(n^2). Indexes have no effect on the virtual table. Possible? Yes. Performant? No, unless the table is small in which case you may not notice."
] | 2018-10-01T16:18:49 | 2018-10-02T07:02:01 | 2018-10-01T16:27:28 | NONE | null | I'm working on a database for notes.
The Notes table uses a non-integer primary key with hash text ids.
I would like to do fulltext search on the notes, so I wanted to use the FTS functionality of SQLite, but I see that the main id there is an integer.
The typical peewee example proceeds like:
```
query = (Entry
.select()
.join(FTSEntry, on=(Entry.id == FTSEntry.docid))
.where(FTSEntry.match('javascript AND canvas')))
```
But in my case the INTEGER docid does not correspond to the TEXT id.
What's the best approach to make a search query in this scenario? | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1745/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1745/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1744 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1744/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1744/comments | https://api.github.com/repos/coleifer/peewee/issues/1744/events | https://github.com/coleifer/peewee/issues/1744 | 365,177,166 | MDU6SXNzdWUzNjUxNzcxNjY= | 1,744 | NameError: name 'EnclosedClause' is not defined | {
"login": "jberkel",
"id": 18891,
"node_id": "MDQ6VXNlcjE4ODkx",
"avatar_url": "https://avatars.githubusercontent.com/u/18891?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/jberkel",
"html_url": "https://github.com/jberkel",
"followers_url": "https://api.github.com/users/jberkel/followers",
"following_url": "https://api.github.com/users/jberkel/following{/other_user}",
"gists_url": "https://api.github.com/users/jberkel/gists{/gist_id}",
"starred_url": "https://api.github.com/users/jberkel/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/jberkel/subscriptions",
"organizations_url": "https://api.github.com/users/jberkel/orgs",
"repos_url": "https://api.github.com/users/jberkel/repos",
"events_url": "https://api.github.com/users/jberkel/events{/privacy}",
"received_events_url": "https://api.github.com/users/jberkel/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"Oversight on my part -- fixed. Thanks for reporting!"
] | 2018-09-30T00:03:57 | 2018-09-30T12:40:37 | 2018-09-30T12:40:03 | CONTRIBUTOR | null | After upgrading to 3.x some FTS-related code stopped working:
```
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/jan/projects/lexi/importer/src/test/python/test_search.py", line 8, in setUp
self.reindex()
File "/Users/jan/projects/lexi/importer/src/test/python/test_search.py", line 18, in reindex
FTSHeadword.reindex()
File "/Users/jan/projects/lexi/importer/src/main/python/lexi/models/fts.py", line 27, in reindex
cls.optimize()
File "/Users/jan/projects/lexi/importer/src/main/python/lexi/models/fts.py", line 55, in optimize
return cls._fts_cmd('optimize')
File "/Users/jan/projects/lexi/importer/build/virtual-env-python3/lib/python3.6/site-packages/playhouse/sqlite_ext.py", line 627, in _fts_cmd
inner_clause = EnclosedClause(tbl)
NameError: name 'EnclosedClause' is not defined
```
Looks like `EnclosedClause` was removed in 3.x, but sqlite_ext still refers to it? | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1744/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1744/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1743 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1743/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1743/comments | https://api.github.com/repos/coleifer/peewee/issues/1743/events | https://github.com/coleifer/peewee/pull/1743 | 365,155,331 | MDExOlB1bGxSZXF1ZXN0MjE5MTYyMjg2 | 1,743 | Adds support for MySQL SSL connection kwargs | {
"login": "jwilner",
"id": 1879661,
"node_id": "MDQ6VXNlcjE4Nzk2NjE=",
"avatar_url": "https://avatars.githubusercontent.com/u/1879661?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/jwilner",
"html_url": "https://github.com/jwilner",
"followers_url": "https://api.github.com/users/jwilner/followers",
"following_url": "https://api.github.com/users/jwilner/following{/other_user}",
"gists_url": "https://api.github.com/users/jwilner/gists{/gist_id}",
"starred_url": "https://api.github.com/users/jwilner/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/jwilner/subscriptions",
"organizations_url": "https://api.github.com/users/jwilner/orgs",
"repos_url": "https://api.github.com/users/jwilner/repos",
"events_url": "https://api.github.com/users/jwilner/events{/privacy}",
"received_events_url": "https://api.github.com/users/jwilner/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [] | 2018-09-29T18:23:43 | 2018-09-30T12:27:28 | 2018-09-30T12:27:28 | NONE | null | Addresses https://github.com/coleifer/peewee/issues/1742
To configure SSL connections with MySQL,`MySQLdb.connect` expects a dictionary of SSL params. Currently, `playhouse.db_url` logic provides no way of parameterizing an SSL connection via the URI. This pull request apes `SQLAlchemy` by letting users specify nested ssl params in the query string with `ssl_*`.
There should be no backwards compatibility issues, because `ssl_` prefixed query params would've previously had no effect. | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1743/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1743/timeline | null | null | false | {
"url": "https://api.github.com/repos/coleifer/peewee/pulls/1743",
"html_url": "https://github.com/coleifer/peewee/pull/1743",
"diff_url": "https://github.com/coleifer/peewee/pull/1743.diff",
"patch_url": "https://github.com/coleifer/peewee/pull/1743.patch",
"merged_at": null
} |
https://api.github.com/repos/coleifer/peewee/issues/1742 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1742/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1742/comments | https://api.github.com/repos/coleifer/peewee/issues/1742/events | https://github.com/coleifer/peewee/issues/1742 | 365,153,762 | MDU6SXNzdWUzNjUxNTM3NjI= | 1,742 | support sqlalchemy-style MySQL URI parameters | {
"login": "jwilner",
"id": 1879661,
"node_id": "MDQ6VXNlcjE4Nzk2NjE=",
"avatar_url": "https://avatars.githubusercontent.com/u/1879661?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/jwilner",
"html_url": "https://github.com/jwilner",
"followers_url": "https://api.github.com/users/jwilner/followers",
"following_url": "https://api.github.com/users/jwilner/following{/other_user}",
"gists_url": "https://api.github.com/users/jwilner/gists{/gist_id}",
"starred_url": "https://api.github.com/users/jwilner/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/jwilner/subscriptions",
"organizations_url": "https://api.github.com/users/jwilner/orgs",
"repos_url": "https://api.github.com/users/jwilner/repos",
"events_url": "https://api.github.com/users/jwilner/events{/privacy}",
"received_events_url": "https://api.github.com/users/jwilner/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"I think I'm going to pass. MySQL-Connector uses different arguments: https://dev.mysql.com/doc/connector-python/en/connector-python-connectargs.html\r\n\r\nI think this is going a bit above and beyond what the db url module was intended to do."
] | 2018-09-29T18:01:31 | 2018-09-30T12:27:17 | 2018-09-30T12:27:17 | NONE | null | The MySQL driver expects a dictionary of SSL parameters -- `{"cert": cert, "key": pkey, "ca": ca}`. SQLAlchemy supports these as URI components prefixed with `ssl` -- e.g. `?ssl_cert={cert}&ssl_key={pkey}&ssl_ca={ca}`. Currently, `playhouse.db_uri` has no comparable behavior, because although it parses out many types from the query string, it doesn't support nested objects.
I propose that `playhouse.db_uri` add a special case for the MySQL URIs which will support the same query params.
Basic idea would be that at the end of `parseresult_to_dict`, an additional postprocessing step would occur which would look like:
```python
if parsed.scheme == "mysql":
_nest_by_prefix(connect_kwargs, prefix="ssl_", new_key="ssl")
``` | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1742/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1742/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1741 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1741/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1741/comments | https://api.github.com/repos/coleifer/peewee/issues/1741/events | https://github.com/coleifer/peewee/pull/1741 | 365,152,584 | MDExOlB1bGxSZXF1ZXN0MjE5MTYwNTQx | 1,741 | Add support for quoted creds | {
"login": "jwilner",
"id": 1879661,
"node_id": "MDQ6VXNlcjE4Nzk2NjE=",
"avatar_url": "https://avatars.githubusercontent.com/u/1879661?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/jwilner",
"html_url": "https://github.com/jwilner",
"followers_url": "https://api.github.com/users/jwilner/followers",
"following_url": "https://api.github.com/users/jwilner/following{/other_user}",
"gists_url": "https://api.github.com/users/jwilner/gists{/gist_id}",
"starred_url": "https://api.github.com/users/jwilner/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/jwilner/subscriptions",
"organizations_url": "https://api.github.com/users/jwilner/orgs",
"repos_url": "https://api.github.com/users/jwilner/repos",
"events_url": "https://api.github.com/users/jwilner/events{/privacy}",
"received_events_url": "https://api.github.com/users/jwilner/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"Merged an equivalent patch, thanks for providing this. I didn't think it was sensible to unquote the username so I removed that logic and changed the parameter to \"unquote_password\" (vs \"unquote_creds\")."
] | 2018-09-29T17:46:42 | 2018-09-30T12:22:22 | 2018-09-30T12:22:22 | NONE | null | Addresses https://github.com/coleifer/peewee/issues/1740
- Maintains backwards compatibility by defaulting to current behavior
- Adds flag to all entry points.
- Tests default behavior is preserved but flag provides new behavior. | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1741/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1741/timeline | null | null | false | {
"url": "https://api.github.com/repos/coleifer/peewee/pulls/1741",
"html_url": "https://github.com/coleifer/peewee/pull/1741",
"diff_url": "https://github.com/coleifer/peewee/pull/1741.diff",
"patch_url": "https://github.com/coleifer/peewee/pull/1741.patch",
"merged_at": null
} |
https://api.github.com/repos/coleifer/peewee/issues/1740 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1740/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1740/comments | https://api.github.com/repos/coleifer/peewee/issues/1740/events | https://github.com/coleifer/peewee/issues/1740 | 365,150,969 | MDU6SXNzdWUzNjUxNTA5Njk= | 1,740 | `playhouse.db_uri.connect` doesn't support db passwords requiring escape | {
"login": "jwilner",
"id": 1879661,
"node_id": "MDQ6VXNlcjE4Nzk2NjE=",
"avatar_url": "https://avatars.githubusercontent.com/u/1879661?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/jwilner",
"html_url": "https://github.com/jwilner",
"followers_url": "https://api.github.com/users/jwilner/followers",
"following_url": "https://api.github.com/users/jwilner/following{/other_user}",
"gists_url": "https://api.github.com/users/jwilner/gists{/gist_id}",
"starred_url": "https://api.github.com/users/jwilner/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/jwilner/subscriptions",
"organizations_url": "https://api.github.com/users/jwilner/orgs",
"repos_url": "https://api.github.com/users/jwilner/repos",
"events_url": "https://api.github.com/users/jwilner/events{/privacy}",
"received_events_url": "https://api.github.com/users/jwilner/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"Merged an equivalent patch, with the difference being that it does not include logic to unquote the username -- just the password."
] | 2018-09-29T17:26:14 | 2018-09-30T12:21:10 | 2018-09-30T12:20:33 | NONE | null | ## the problem
To provide a password (or username) with characters unsafe for a URI, users must escape them to include them in the authority of a URI. However, the standard python password url parse logic -- `urllib.parse(uri).password` -- doesn't automatically unquote a password; clients of that code must . As it is, Peewee currently does not.
As a brief reproduction:
```bash
docker run \
--name peewee-test \
--rm \
--detach \
--publish=3306:3306 \
--env "MYSQL_ROOT_PASSWORD=abcd#hijk" \
--env "MYSQL_DATABASE=peewee-test" \
mysql:5.7
```
and then:
```python
from playhouse.db_url import connect
from urllib.parse import quote
password = "abcd#hijk"
# ValueError within urllib.parse because parser reads '#' as start of fragment
connect(f"mysql://root:{password}@127.0.0.1:3306/peewee-test").connect()
# access denied because not unquoted
connect(f"mysql://root:{quote(password)}@127.0.0.1:3306/peewee-test").connect()
```
Tested with peewee==3.7.0 FWIW.
## The proposal
Many libraries using URIs as connection string implicitly unquote the username and password. I suggest playhouse add the same ability while providing backward compatibility for those current users whose passwords `unquote` might break (those who have the sequence which I imagine would be very very rare, but still).
```python
def connect(url, unquote_creds=False, **connect_params):
pass
``` | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1740/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1740/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1739 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1739/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1739/comments | https://api.github.com/repos/coleifer/peewee/issues/1739/events | https://github.com/coleifer/peewee/issues/1739 | 365,134,432 | MDU6SXNzdWUzNjUxMzQ0MzI= | 1,739 | 3.x index renaming | {
"login": "jberkel",
"id": 18891,
"node_id": "MDQ6VXNlcjE4ODkx",
"avatar_url": "https://avatars.githubusercontent.com/u/18891?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/jberkel",
"html_url": "https://github.com/jberkel",
"followers_url": "https://api.github.com/users/jberkel/followers",
"following_url": "https://api.github.com/users/jberkel/following{/other_user}",
"gists_url": "https://api.github.com/users/jberkel/gists{/gist_id}",
"starred_url": "https://api.github.com/users/jberkel/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/jberkel/subscriptions",
"organizations_url": "https://api.github.com/users/jberkel/orgs",
"repos_url": "https://api.github.com/users/jberkel/repos",
"events_url": "https://api.github.com/users/jberkel/events{/privacy}",
"received_events_url": "https://api.github.com/users/jberkel/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"I'm not seeing that, actually. I added a testcase which to me validates that the behavior in 3.x respects the table name as the prefix.\r\n\r\n47170c381329057f26ee5fb121eef54dbb7944e3",
"Thanks for investigating, found the issue. I wasn't using `legacy_table_names = False`.",
"When using legacy table names, Peewee will prefix the index with the model name, irrespective of the actual table name."
] | 2018-09-29T13:55:40 | 2018-09-30T22:05:25 | 2018-09-30T12:10:45 | CONTRIBUTOR | null | I'm not sure if this is working as intended, but after upgrading to 3.x I get a different schema because of index renames.
I use `table_name` to set the table name, but the index name seems to use the automatic table name as prefix, e.g.
```python
class Foo
some_text = TextField(index=True)
class Meta
table_name = "foos"
````
results in `CREATE INDEX "foo_some_text" ON "foos" ("some_text")` and not `CREATE INDEX "foos_some_text" ON "foos" ("some_text")` as it did previously. | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1739/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1739/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1738 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1738/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1738/comments | https://api.github.com/repos/coleifer/peewee/issues/1738/events | https://github.com/coleifer/peewee/issues/1738 | 364,534,534 | MDU6SXNzdWUzNjQ1MzQ1MzQ= | 1,738 | Incorrect sql generated by custom field | {
"login": "fy0",
"id": 1579850,
"node_id": "MDQ6VXNlcjE1Nzk4NTA=",
"avatar_url": "https://avatars.githubusercontent.com/u/1579850?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/fy0",
"html_url": "https://github.com/fy0",
"followers_url": "https://api.github.com/users/fy0/followers",
"following_url": "https://api.github.com/users/fy0/following{/other_user}",
"gists_url": "https://api.github.com/users/fy0/gists{/gist_id}",
"starred_url": "https://api.github.com/users/fy0/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/fy0/subscriptions",
"organizations_url": "https://api.github.com/users/fy0/orgs",
"repos_url": "https://api.github.com/users/fy0/repos",
"events_url": "https://api.github.com/users/fy0/events{/privacy}",
"received_events_url": "https://api.github.com/users/fy0/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"In 3.x you need to use `field_type` instead of `db_field`. The docs are pretty clear:\r\n\r\nhttp://docs.peewee-orm.com/en/latest/peewee/models.html#creating-a-custom-field",
"@coleifer Sorry, in fact I had read the document before, but copy & paste my old code in the same file when I programming..."
] | 2018-09-27T15:33:52 | 2018-09-27T16:55:08 | 2018-09-27T16:07:02 | NONE | null | My database is PostgreSQL.
Field:
```
class INETField(peewee.Field):
db_field = 'inet'
```
Model:
```
reputation = IntegerField(default=0)
ip_registered = INETField(default=None, null=True)
```
Error:
```
cursor.execute(sql, params or ())
peewee.ProgrammingError: syntax error at or near ","
LINE 1: ...L, "reputation" INTEGER NOT NULL, "ip_registered" , "reset_k...
```
type, default and "not null" lost.
An old version: 3.5.2
Upgraded to 3.7.0, it still happened.
Is it a bug or some thing wrong with my code? | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1738/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1738/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1737 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1737/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1737/comments | https://api.github.com/repos/coleifer/peewee/issues/1737/events | https://github.com/coleifer/peewee/issues/1737 | 364,439,523 | MDU6SXNzdWUzNjQ0Mzk1MjM= | 1,737 | Postgres ON CONFLICT for a named index | {
"login": "Nelluk",
"id": 2545428,
"node_id": "MDQ6VXNlcjI1NDU0Mjg=",
"avatar_url": "https://avatars.githubusercontent.com/u/2545428?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/Nelluk",
"html_url": "https://github.com/Nelluk",
"followers_url": "https://api.github.com/users/Nelluk/followers",
"following_url": "https://api.github.com/users/Nelluk/following{/other_user}",
"gists_url": "https://api.github.com/users/Nelluk/gists{/gist_id}",
"starred_url": "https://api.github.com/users/Nelluk/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/Nelluk/subscriptions",
"organizations_url": "https://api.github.com/users/Nelluk/orgs",
"repos_url": "https://api.github.com/users/Nelluk/repos",
"events_url": "https://api.github.com/users/Nelluk/events{/privacy}",
"received_events_url": "https://api.github.com/users/Nelluk/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"I have no clue why that is, because Postgres will infer the correct unique index if the columns are provided.\r\n\r\nFor example:\r\n\r\n```python\r\n\r\nclass KV(Model):\r\n key = TextField()\r\n value = TextField()\r\n extra = TextField(default='')\r\n class Meta:\r\n database = db\r\n indexes = ((('key', 'value'), True),)\r\n\r\nKV.create(key='k1', value='v1')\r\nKV.create(key='k2', value='v2')\r\n\r\n(KV\r\n .insert(key='k1', value='v1', extra='e1')\r\n .on_conflict(conflict_target=[KV.key, KV.value], preserve=[KV.extra])\r\n .execute())\r\n\r\nkv = KV.get(KV.key == 'k1')\r\nprint(kv.__data__)\r\n# {'id': 1, 'key': 'k1', 'value': 'v1', 'extra': 'e1'}\r\n```\r\n\r\nLooking at the schema, I see:\r\n\r\n```\r\n# \\d kv\r\n Table \"public.kv\"\r\n Column | Type | Collation | Nullable | Default \r\n--------+---------+-----------+----------+--------------------------------\r\n id | integer | | not null | nextval('kv_id_seq'::regclass)\r\n key | text | | not null | \r\n value | text | | not null | \r\n extra | text | | not null | \r\nIndexes:\r\n \"kv_pkey\" PRIMARY KEY, btree (id)\r\n \"kv_key_value\" UNIQUE, btree (key, value)\r\n```\r\n\r\nHowever, if I execute the following in the postgres shell, I get an error:\r\n\r\n```sql\r\ninsert into kv (key, value, extra) values ('k2', 'v2', 'e2') \r\n on conflict (\"kv_key_value\") do update set extra=EXCLUDED.extra \r\n returning id;\r\nERROR: column \"kv_key_value\" does not exist\r\n```\r\n\r\nEven creating a named constraint doesn't seem to work:\r\n\r\n```sql\r\ncreate table kv (\r\n id serial not null, \r\n key text not null, \r\n value text not null, \r\n extra text not null default '', \r\n constraint kv_key_value unique(key, value));\r\n```\r\n\r\nWhich produces slightly different output when describing:\r\n\r\n```\r\n\\d kv\r\n Table \"public.kv\"\r\n Column | Type | Collation | Nullable | Default \r\n--------+---------+-----------+----------+--------------------------------\r\n id | integer | | not null | nextval('kv_id_seq'::regclass)\r\n key | text | | not null | \r\n value | text | | not null | \r\n extra | text | | not null | ''::text\r\nIndexes:\r\n \"kv_key_value\" UNIQUE CONSTRAINT, btree (key, value) -- NOTE the \"CONSTRAINT\" bit.\r\n```\r\n\r\nHowever this fails in the same way, with the \"column ... does not exist\" error. I'm not sure why this is. I've created a question on StackOverflow with all the info from this comment:\r\n\r\nhttps://stackoverflow.com/questions/52542845/postgresql-on-conflict-with-multi-column-unique-constraint-name\r\n\r\nNote the postgres docs say:\r\n\r\n> It is often preferable to use unique index inference rather than naming a constraint directly using ON CONFLICT ON CONSTRAINT constraint_name.\r\n\r\nBut I still don't get why the constraint name is not working. Weird.",
"Thanks to Tom L. from the Postgres mailing list and Laurenz A. on stackoverflow for clarifying the problem. When referencing a constraint, the syntax is:\r\n\r\n```sql\r\nON CONFLICT ON CONSTRAINT constraint_name\r\n```\r\n\r\nSo I'll need to update Peewee to include the \"ON CONSTRAINT\" bit where appropriate.",
"Pushed a fix, but please note that you cannot specify the name of a UNIQUE index (for whatever reason). The constraint name must be the name of a table constraint, which you can create like so:\r\n\r\n```python\r\nclass KV(Model):\r\n key = TextField()\r\n value = TextField()\r\n\r\n class Meta:\r\n constraints = [SQL('constraint kv_key_value unique(key, value)')]\r\n```\r\n\r\nAlso note that to specify the name, you will use `.on_conflict(conflict_constraint='kv_key_value')` rather than `conflict_target=...`, which is now reserved for index expressions."
] | 2018-09-27T11:57:31 | 2018-09-27T19:39:14 | 2018-09-27T19:37:15 | NONE | null | I have a table Player with a unique index on two columns. I am trying to do an UPSERT with this index as the ON CONFLICT target.
```python
class Player(BaseModel):
discord_member = ForeignKeyField(DiscordMember, unique=False, null=False)
guild_id = BitField(unique=False, null=False)
nick = TextField(unique=False, null=True)
team = ForeignKeyField(Team, null=True, backref='player')
def upsert(discord_member_obj, guild_id, team=None):
discord_member, _ = DiscordMember.get_or_create(discord_id=discord_member_obj.id, defaults={'name': discord_member_obj.name})
player = Player.insert(discord_member=discord_member, guild_id=guild_id, nick=discord_member_obj.nick, team=team).on_conflict(
# conflict_target=[Player.discord_member, Player.guild_id],
# conflict_target=[idx],
conflict_target=['playerindex'],
# conflict_target=['player.playerindex'],
preserve=[Player.team]
).execute()
return player
# class Meta:
# indexes = ((('discord_member', 'guild_id'), True),) # Trailing comma is required
idx = Player.index(Player.discord_member, Player.guild_id, unique=True, name='playerindex')
Player.add_index(idx)
```
Initially I was using the easier Meta index, but could not find a way to refer to it in the `conflict_target`. Then I moved on to more advanced index creation and assigned a name to the index, but I cannot find a way to refer to the name. Above are a few methods I've tried commented out.
I've confirmed with psql that the index exists:
```
Indexes:
"player_pkey" PRIMARY KEY, btree (id)
"playerindex" UNIQUE, btree (discord_member_id, guild_id)
```
My guess is that postgres wants the index referred to without quotation marks perhaps, but peewee is inserting them?
`peewee.ProgrammingError: column "playerindex" does not exist`
`LINE 1: ...478571892832206869, NULL, NULL, 1000) ON CONFLICT ("playerin..`
| {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1737/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1737/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1736 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1736/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1736/comments | https://api.github.com/repos/coleifer/peewee/issues/1736/events | https://github.com/coleifer/peewee/issues/1736 | 364,246,221 | MDU6SXNzdWUzNjQyNDYyMjE= | 1,736 | `sqlall()`gone missing in 3.x | {
"login": "jberkel",
"id": 18891,
"node_id": "MDQ6VXNlcjE4ODkx",
"avatar_url": "https://avatars.githubusercontent.com/u/18891?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/jberkel",
"html_url": "https://github.com/jberkel",
"followers_url": "https://api.github.com/users/jberkel/followers",
"following_url": "https://api.github.com/users/jberkel/following{/other_user}",
"gists_url": "https://api.github.com/users/jberkel/gists{/gist_id}",
"starred_url": "https://api.github.com/users/jberkel/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/jberkel/subscriptions",
"organizations_url": "https://api.github.com/users/jberkel/orgs",
"repos_url": "https://api.github.com/users/jberkel/repos",
"events_url": "https://api.github.com/users/jberkel/events{/privacy}",
"received_events_url": "https://api.github.com/users/jberkel/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"> I could easily reproduce this with some extra lines of code\r\n\r\nGo for it.\r\n\r\nUpdated the changes documentation to reflect the removal of this. Apologies for the confusion."
] | 2018-09-26T23:08:19 | 2018-09-27T03:09:46 | 2018-09-27T03:09:46 | CONTRIBUTOR | null | I'm just migrating a bunch of code from 2.x to 3.x. Nice job! My code previously used `Model.sqlall()` to create a file with the current SQL schema. This method is gone in 3.x, and I don't see a replacement for it. I could easily reproduce this with some extra lines of code but I still think it's a worthwhile method to have, if only for quick debugging of schemas. | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1736/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1736/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1735 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1735/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1735/comments | https://api.github.com/repos/coleifer/peewee/issues/1735/events | https://github.com/coleifer/peewee/issues/1735 | 362,861,466 | MDU6SXNzdWUzNjI4NjE0NjY= | 1,735 | How to use TO_CHAR function | {
"login": "Maheshkumar094",
"id": 39484115,
"node_id": "MDQ6VXNlcjM5NDg0MTE1",
"avatar_url": "https://avatars.githubusercontent.com/u/39484115?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/Maheshkumar094",
"html_url": "https://github.com/Maheshkumar094",
"followers_url": "https://api.github.com/users/Maheshkumar094/followers",
"following_url": "https://api.github.com/users/Maheshkumar094/following{/other_user}",
"gists_url": "https://api.github.com/users/Maheshkumar094/gists{/gist_id}",
"starred_url": "https://api.github.com/users/Maheshkumar094/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/Maheshkumar094/subscriptions",
"organizations_url": "https://api.github.com/users/Maheshkumar094/orgs",
"repos_url": "https://api.github.com/users/Maheshkumar094/repos",
"events_url": "https://api.github.com/users/Maheshkumar094/events{/privacy}",
"received_events_url": "https://api.github.com/users/Maheshkumar094/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"To translate:\r\n\r\n```sql\r\nTO_CHAR(created_at at time zone 'Asia/Kolkata','DD-MON-YYYY') as date\r\n```\r\n\r\nYou'll probably need to use NodeList:\r\n\r\n```python\r\nexpr = NodeList((Txn.created_at, SQL('at time zone'), 'Asia/Kolkata'))\r\ndate_expr = fn.TO_CHAR(expr, 'DD-MON-YYYY')\r\n\r\n...select(Txn.id, date_expr.alias('date'))\r\n```",
"Tnx:)"
] | 2018-09-22T14:30:21 | 2018-09-22T17:55:51 | 2018-09-22T16:39:50 | NONE | null | @coleifer
How to use postgress TO_CHAR function in peewee
In native sql query
`SELECT id, TO_CHAR(created_at at time zone 'Asia/Kolkata','DD-MON-YYYY') as date from txn order by id desc limit 5`
-------------------------------- result ------------------------------
**id date**
131; "19-SEP-2018"
130; "19-SEP-2018"
129; "19-SEP-2018"
128; "19-SEP-2018"
127; "13-SEP-2018"
In peewee
```
class Txn(BaseModel):
created_at = DateTimeField(null=True)
class Meta:
table_name = 'txn'
schema = 'public'
```
what I figure out
```
def getprvtxn(passenger_id):
try:
query_get_txn_his = Txn.select(
Txn.id,
fn.TO_CHAR(Txn.created_at,"at time zone'Asia/Kolkata'DD-MON-YYYY HH12:MIPM").alias('date')
).where(Txn.passenger == passenger_id).order_by(Txn.created_at).limit(30)
print(list(query_get_txn_his.dicts()))
print("SQL ={}".format(query_get_txn_his.sql()))
if query_get_txn_his.__sizeof__() > 0 and bool(query_get_txn_his):
for result in query_get_txn_his:
print result.id
print(result.date)
except Exception as e:
cnf.is_error = True
cnf.statuscode = cnf.Internal_server_Error
tb.print_exc()
return None
```
--------------------------- Peewee Result ------------------------
```
id = 16 date = at t8me zone'As8a/Kolkata'17-AUG-2018 02:29PM
id = 17 date = at t8me zone'As8a/Kolkata'17-AUG-2018 02:29PM
id = 32 date = at t8me zone'As8a/Kolkata'20-AUG-2018 12:56PM
id = 33 date = at t8me zone'As8a/Kolkata'20-AUG-2018 01:02PM
id = 34 date = at t8me zone'As8a/Kolkata'20-AUG-2018 01:13PM
id = 35 date = at t8me zone'As8a/Kolkata'20-AUG-2018 01:14PM
id = 36 date = at t8me zone'As8a/Kolkata'20-AUG-2018 01:14PM
id = 37 date = at t8me zone'As8a/Kolkata'20-AUG-2018 01:16PM
id = 38 date = at t8me zone'As8a/Kolkata'20-AUG-2018 02:20PM
id = 39 date = at t8me zone'As8a/Kolkata'20-AUG-2018 02:38PM
```
You notice that **_at t8me zone'As8a/Kolkata'_** is append with **20-AUG-2018 02:38PM** which not the desire output. Plase me with correct soluntion and correct way to use postgress function in peewee:)
| {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1735/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1735/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1734 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1734/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1734/comments | https://api.github.com/repos/coleifer/peewee/issues/1734/events | https://github.com/coleifer/peewee/issues/1734 | 362,752,110 | MDU6SXNzdWUzNjI3NTIxMTA= | 1,734 | Psycopg2 warning | {
"login": "yabirgb",
"id": 5068010,
"node_id": "MDQ6VXNlcjUwNjgwMTA=",
"avatar_url": "https://avatars.githubusercontent.com/u/5068010?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/yabirgb",
"html_url": "https://github.com/yabirgb",
"followers_url": "https://api.github.com/users/yabirgb/followers",
"following_url": "https://api.github.com/users/yabirgb/following{/other_user}",
"gists_url": "https://api.github.com/users/yabirgb/gists{/gist_id}",
"starred_url": "https://api.github.com/users/yabirgb/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/yabirgb/subscriptions",
"organizations_url": "https://api.github.com/users/yabirgb/orgs",
"repos_url": "https://api.github.com/users/yabirgb/repos",
"events_url": "https://api.github.com/users/yabirgb/events{/privacy}",
"received_events_url": "https://api.github.com/users/yabirgb/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"That doesn't sound correct at all. `psycopg2-binary` should install a psycopg2 package normally. It's just a binary package rather than a source package.",
"See:\r\n\r\n```\r\n$ pip freeze | grep psycopg2\r\n65:psycopg2-binary==2.7.5\r\n\r\n$ ipython\r\nPython 3.7.0 (default, Jul 15 2018, 18:17:02) \r\nType 'copyright', 'credits' or 'license' for more information\r\nIPython 6.4.0 -- An enhanced Interactive Python. Type '?' for help.\r\n\r\nIn [1]: from peewee import PostgresqlDatabase\r\n\r\nIn [2]: db = PostgresqlDatabase('peewee_test')\r\n\r\nIn [3]: db.connect()\r\nOut[3]: True\r\n```",
"Ok thanks! I will check then what other thing could be failing. Sorry for the inconvenience"
] | 2018-09-21T19:49:24 | 2018-09-22T16:48:39 | 2018-09-21T22:48:04 | NONE | null | I get this warning when running peewee with postgresql:
`UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.`
If I uninstall `psycopg2` and install `psycopg2-binary` I get the error `peewee.ImproperlyConfigured: Postgres driver not installed!` | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1734/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1734/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1733 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1733/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1733/comments | https://api.github.com/repos/coleifer/peewee/issues/1733/events | https://github.com/coleifer/peewee/issues/1733 | 362,606,901 | MDU6SXNzdWUzNjI2MDY5MDE= | 1,733 | id field value is None | {
"login": "jbriales",
"id": 6850478,
"node_id": "MDQ6VXNlcjY4NTA0Nzg=",
"avatar_url": "https://avatars.githubusercontent.com/u/6850478?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/jbriales",
"html_url": "https://github.com/jbriales",
"followers_url": "https://api.github.com/users/jbriales/followers",
"following_url": "https://api.github.com/users/jbriales/following{/other_user}",
"gists_url": "https://api.github.com/users/jbriales/gists{/gist_id}",
"starred_url": "https://api.github.com/users/jbriales/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/jbriales/subscriptions",
"organizations_url": "https://api.github.com/users/jbriales/orgs",
"repos_url": "https://api.github.com/users/jbriales/repos",
"events_url": "https://api.github.com/users/jbriales/events{/privacy}",
"received_events_url": "https://api.github.com/users/jbriales/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"Uh... I know for a fact that something as fundamental as retrieving a column value from a select query is working -- it's covered quite thoroughly in the tests.\r\n\r\nPerhaps you can provide a test-case or complete script so I can replicate the issue?",
"Ok, you are fully right. Your mention of tests gave me an idea.\r\nI tried tests and a simpler toy example and it revealed I had done some (apparently) small change inside peewee which however provoked this malfunctioning...\r\nWorking fine now! Sorry for the false alarm :)"
] | 2018-09-21T13:05:41 | 2018-09-21T15:19:19 | 2018-09-21T15:19:18 | NONE | null | I'm trying to get the id field of a SQLite table but I always get None:
# Model:
```
class Document(BaseModel):
id = IntegerField(db_column='id', primary_key=True, null=False, index=True)
class Meta:
db_table = 'Documents'
```
# Query:
```
query = Document.select()
with db.atomic():
for doc in query:
print(doc.id)
```
The id field exists in the table as
`id` INTEGER PRIMARY KEY AUTOINCREMENT | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1733/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1733/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1732 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1732/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1732/comments | https://api.github.com/repos/coleifer/peewee/issues/1732/events | https://github.com/coleifer/peewee/issues/1732 | 362,567,158 | MDU6SXNzdWUzNjI1NjcxNTg= | 1,732 | sqlite database stores 'true'/'false' in INT type | {
"login": "jbriales",
"id": 6850478,
"node_id": "MDQ6VXNlcjY4NTA0Nzg=",
"avatar_url": "https://avatars.githubusercontent.com/u/6850478?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/jbriales",
"html_url": "https://github.com/jbriales",
"followers_url": "https://api.github.com/users/jbriales/followers",
"following_url": "https://api.github.com/users/jbriales/following{/other_user}",
"gists_url": "https://api.github.com/users/jbriales/gists{/gist_id}",
"starred_url": "https://api.github.com/users/jbriales/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/jbriales/subscriptions",
"organizations_url": "https://api.github.com/users/jbriales/orgs",
"repos_url": "https://api.github.com/users/jbriales/repos",
"events_url": "https://api.github.com/users/jbriales/events{/privacy}",
"received_events_url": "https://api.github.com/users/jbriales/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"> I'm not very familiar with databases, so I don't know if this that Mendeley does is a very unusual behavior, or why wouldn't they just store 0/1, but this is out of my control. So I was wondering which could be the best approach to deal with this issue.\r\n\r\nThis is very bad behavior, in my opinion.\r\n\r\nYou can do one of several things:\r\n\r\n* Update the tables, e.g. `update my_table set my_col = case when my_col='true' then 1 else 0 end;`\r\n* Implement a custom field type that correctly handles the strings \"true\" / \"false\"\r\n\r\nThere's no excuse for monkey-patching `IntegerField.adapt` in my opinion...just subclass. It's Python."
] | 2018-09-21T11:08:50 | 2018-09-22T02:21:45 | 2018-09-22T02:21:45 | NONE | null | I'm using peewee to handle the database stored by the Mendeley app.
It turns out in its database Mendeley defines binary fields as INT but populate its values with 'true'/'false' strings.
As a result, when reading this database through the models automatically imported by pwiz (which parses these fields as 'IntegerField'), the program throws an exception as it tries to cast `int('true')`.
I'm not very familiar with databases, so I don't know if this that Mendeley does is a very unusual behavior, or why wouldn't they just store 0/1, but this is out of my control. So I was wondering which could be the best approach to deal with this issue.
Should I force the `IntegerField.adapt` method to check if the string is 'true' or 'false' in case of exception? This seems a little invasive though wrt peewee, that's why I ask for advice here :) | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1732/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1732/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1731 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1731/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1731/comments | https://api.github.com/repos/coleifer/peewee/issues/1731/events | https://github.com/coleifer/peewee/pull/1731 | 362,520,733 | MDExOlB1bGxSZXF1ZXN0MjE3MjE2ODc2 | 1,731 | Match FLOAT and CHAR[...] in sqlite reflection. | {
"login": "jbriales",
"id": 6850478,
"node_id": "MDQ6VXNlcjY4NTA0Nzg=",
"avatar_url": "https://avatars.githubusercontent.com/u/6850478?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/jbriales",
"html_url": "https://github.com/jbriales",
"followers_url": "https://api.github.com/users/jbriales/followers",
"following_url": "https://api.github.com/users/jbriales/following{/other_user}",
"gists_url": "https://api.github.com/users/jbriales/gists{/gist_id}",
"starred_url": "https://api.github.com/users/jbriales/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/jbriales/subscriptions",
"organizations_url": "https://api.github.com/users/jbriales/orgs",
"repos_url": "https://api.github.com/users/jbriales/repos",
"events_url": "https://api.github.com/users/jbriales/events{/privacy}",
"received_events_url": "https://api.github.com/users/jbriales/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"So SQLite only supports the following data-types:\r\n\r\n* TEXT\r\n* BLOB\r\n* INTEGER\r\n* REAL\r\n* NULL\r\n\r\nI think I'm going to pass on the square bracket change, but will add support for float along with some others:\r\n\r\nd31e7bf972e69e227c10694fac71b966959e715f"
] | 2018-09-21T09:02:40 | 2018-09-21T13:35:10 | 2018-09-21T13:35:10 | NONE | null | Fix issue related to https://github.com/coleifer/peewee/issues/1730#issuecomment-423461785 | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1731/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1731/timeline | null | null | false | {
"url": "https://api.github.com/repos/coleifer/peewee/pulls/1731",
"html_url": "https://github.com/coleifer/peewee/pull/1731",
"diff_url": "https://github.com/coleifer/peewee/pull/1731.diff",
"patch_url": "https://github.com/coleifer/peewee/pull/1731.patch",
"merged_at": null
} |
https://api.github.com/repos/coleifer/peewee/issues/1730 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1730/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1730/comments | https://api.github.com/repos/coleifer/peewee/issues/1730/events | https://github.com/coleifer/peewee/issues/1730 | 362,068,299 | MDU6SXNzdWUzNjIwNjgyOTk= | 1,730 | VARCHAR not correctly parsed in pwiz | {
"login": "jbriales",
"id": 6850478,
"node_id": "MDQ6VXNlcjY4NTA0Nzg=",
"avatar_url": "https://avatars.githubusercontent.com/u/6850478?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/jbriales",
"html_url": "https://github.com/jbriales",
"followers_url": "https://api.github.com/users/jbriales/followers",
"following_url": "https://api.github.com/users/jbriales/following{/other_user}",
"gists_url": "https://api.github.com/users/jbriales/gists{/gist_id}",
"starred_url": "https://api.github.com/users/jbriales/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/jbriales/subscriptions",
"organizations_url": "https://api.github.com/users/jbriales/orgs",
"repos_url": "https://api.github.com/users/jbriales/repos",
"events_url": "https://api.github.com/users/jbriales/events{/privacy}",
"received_events_url": "https://api.github.com/users/jbriales/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"Thanks, I've fixed the issue where VARCHAR without a length constraint is now recognized correctly with Sqlite -- fdeb92c1639c1dc9301ae501b95e36d83a63ee74\r\n\r\nRegarding the max_length parameter, this has no effect in Sqlite and so it is fine to ignore it:\r\n\r\n```sql\r\nsqlite> create table kv (key varchar(4) not null primary key, value varchar(8) not null);\r\nsqlite> insert into kv (key, value) values ('abcdefghij', '12345678901234567890');\r\nsqlite> select * from kv;\r\nabcdefghij|12345678901234567890\r\n```",
"Thanks for the fix, it's working now :)\r\nHowever I still found two failing cases in my database:\r\n`# CHAR[38]`\r\n`# FLOAT`\r\nI will make a pull request next.",
"Eh.. You know SQLite only supports the following data-types, right?\r\n\r\n* TEXT\r\n* BLOB\r\n* INTEGER\r\n* REAL\r\n* NULL",
"Uhm... just starting with SQL so... why would this database I'm working with have those other fields? Is it maybe not actually SQLite? (although reading/writing to it as a SQLite works)",
"SQLite is permissive about what it accepts, but internally it only knows about the data-types I mentioned."
] | 2018-09-20T08:12:23 | 2018-09-23T01:40:45 | 2018-09-20T14:10:06 | NONE | null | Hi,
I was using pwiz in python3 with sqlite and it seems VARCHAR fields are not correctly parsed:
If no max length is provided, the field is not recognized:
```
CREATE TABLE COMPANY(
ID INT PRIMARY KEY NOT NULL,
NAME VARCHAR NOT NULL,
AGE INT NOT NULL,
ADDRESS TEXT,
SALARY REAL
);
```
```
class Company(BaseModel):
address = TextField(db_column='ADDRESS', null=True)
age = IntegerField(db_column='AGE')
id = PrimaryKeyField(db_column='ID')
name = UnknownField(db_column='NAME') # VARCHAR
salary = FloatField(db_column='SALARY', null=True)
class Meta:
db_table = 'COMPANY'
```
If max length is provided, I don't get it in models.py:
```
CREATE TABLE COMPANY(
ID INT PRIMARY KEY NOT NULL,
NAME VARCHAR(50) NOT NULL,
AGE INT NOT NULL,
ADDRESS TEXT,
SALARY REAL
);
```
```
class Company(BaseModel):
address = TextField(db_column='ADDRESS', null=True)
age = IntegerField(db_column='AGE')
id = PrimaryKeyField(db_column='ID')
name = CharField(db_column='NAME')
salary = FloatField(db_column='SALARY', null=True)
class Meta:
db_table = 'COMPANY'
```
| {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1730/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1730/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1729 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1729/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1729/comments | https://api.github.com/repos/coleifer/peewee/issues/1729/events | https://github.com/coleifer/peewee/issues/1729 | 362,060,895 | MDU6SXNzdWUzNjIwNjA4OTU= | 1,729 | Different syntax for python2 and python3 | {
"login": "jbriales",
"id": 6850478,
"node_id": "MDQ6VXNlcjY4NTA0Nzg=",
"avatar_url": "https://avatars.githubusercontent.com/u/6850478?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/jbriales",
"html_url": "https://github.com/jbriales",
"followers_url": "https://api.github.com/users/jbriales/followers",
"following_url": "https://api.github.com/users/jbriales/following{/other_user}",
"gists_url": "https://api.github.com/users/jbriales/gists{/gist_id}",
"starred_url": "https://api.github.com/users/jbriales/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/jbriales/subscriptions",
"organizations_url": "https://api.github.com/users/jbriales/orgs",
"repos_url": "https://api.github.com/users/jbriales/repos",
"events_url": "https://api.github.com/users/jbriales/events{/privacy}",
"received_events_url": "https://api.github.com/users/jbriales/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"Uhh, it sounds like in one case you are running an old version of Peewee.\r\n\r\nYou can verify by running\r\n\r\n```\r\npython2 -c \"import peewee; print(peewee.__version__)\"\r\npython3 -c \"import peewee; print(peewee.__version__)\"\r\n```"
] | 2018-09-20T07:51:50 | 2018-09-20T13:48:35 | 2018-09-20T13:48:35 | NONE | null | Hi, I'm just starting to use peewee and pwiz, and it took a while to figure out this error:
TypeError: __init__() got an unexpected keyword argument 'column_name'
Apparently the syntax is different in the python2 and python3 versions,
so I got different results calling:
`python2 -m pwiz -e sqlite "testDB.sqlite" > testmodels.py`
`python3 -m pwiz -e sqlite "testDB.sqlite" > testmodels.py`
I installed both versions via pip. | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1729/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1729/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1728 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1728/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1728/comments | https://api.github.com/repos/coleifer/peewee/issues/1728/events | https://github.com/coleifer/peewee/pull/1728 | 361,329,149 | MDExOlB1bGxSZXF1ZXN0MjE2MzI2MTU4 | 1,728 | Added frozenset as mutli type. | {
"login": "conqp",
"id": 3766192,
"node_id": "MDQ6VXNlcjM3NjYxOTI=",
"avatar_url": "https://avatars.githubusercontent.com/u/3766192?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/conqp",
"html_url": "https://github.com/conqp",
"followers_url": "https://api.github.com/users/conqp/followers",
"following_url": "https://api.github.com/users/conqp/following{/other_user}",
"gists_url": "https://api.github.com/users/conqp/gists{/gist_id}",
"starred_url": "https://api.github.com/users/conqp/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/conqp/subscriptions",
"organizations_url": "https://api.github.com/users/conqp/orgs",
"repos_url": "https://api.github.com/users/conqp/repos",
"events_url": "https://api.github.com/users/conqp/events{/privacy}",
"received_events_url": "https://api.github.com/users/conqp/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"Cheers cfa2fa5f4f8ef170c802065fece3d828b7b6da24"
] | 2018-09-18T14:21:10 | 2018-09-18T14:46:19 | 2018-09-18T14:46:18 | CONTRIBUTOR | null | Fixes #1727. | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1728/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1728/timeline | null | null | false | {
"url": "https://api.github.com/repos/coleifer/peewee/pulls/1728",
"html_url": "https://github.com/coleifer/peewee/pull/1728",
"diff_url": "https://github.com/coleifer/peewee/pull/1728.diff",
"patch_url": "https://github.com/coleifer/peewee/pull/1728.patch",
"merged_at": null
} |
https://api.github.com/repos/coleifer/peewee/issues/1727 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1727/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1727/comments | https://api.github.com/repos/coleifer/peewee/issues/1727/events | https://github.com/coleifer/peewee/issues/1727 | 361,326,560 | MDU6SXNzdWUzNjEzMjY1NjA= | 1,727 | Support frozenset for IN / NOT IN queries | {
"login": "conqp",
"id": 3766192,
"node_id": "MDQ6VXNlcjM3NjYxOTI=",
"avatar_url": "https://avatars.githubusercontent.com/u/3766192?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/conqp",
"html_url": "https://github.com/conqp",
"followers_url": "https://api.github.com/users/conqp/followers",
"following_url": "https://api.github.com/users/conqp/following{/other_user}",
"gists_url": "https://api.github.com/users/conqp/gists{/gist_id}",
"starred_url": "https://api.github.com/users/conqp/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/conqp/subscriptions",
"organizations_url": "https://api.github.com/users/conqp/orgs",
"repos_url": "https://api.github.com/users/conqp/repos",
"events_url": "https://api.github.com/users/conqp/events{/privacy}",
"received_events_url": "https://api.github.com/users/conqp/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"Fixed: cfa2fa5f4f8ef170c802065fece3d828b7b6da24\r\n\r\nI merged an equivalent patch which also includes tests. I appreciate the ticket and patch."
] | 2018-09-18T14:15:54 | 2018-09-18T14:47:03 | 2018-09-18T14:46:03 | CONTRIBUTOR | null | So, today I encountered, that `frozenset`s seems not to be supported as type for `<<` (`IN`) queries:
```
>>> list(BaseChart.select().join(GroupBaseChart).where((BaseChart.trashed == 0) & (GroupBaseChart.group << frozenset())))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 5896, in __iter__
self.execute()
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1587, in inner
return method(self, database, *args, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1658, in execute
return self._execute(database)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1809, in _execute
cursor = database.execute(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 2665, in execute
sql, params = ctx.sql(query).query()
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 2028, in __sql__
ctx.literal(' WHERE ').sql(self._where)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1291, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1291, in __sql__
.sql(self.rhs))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 562, in sql
return self.sql(Value(obj))
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 558, in sql
return obj.__sql__(self)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 1215, in __sql__
return ctx.value(self.value, self.converter)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 576, in value
value = self.state.converter(value)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 4454, in db_value
return self.rel_field.db_value(value)
File "/usr/local/lib/python3.4/dist-packages/peewee.py", line 3907, in db_value
return value if value is None else self.adapt(value)
TypeError: int() argument must be a string or a number, not 'frozenset'
>>> list(BaseChart.select().join(GroupBaseChart).where((BaseChart.trashed == 0) & (GroupBaseChart.group << set())))
[]
>>>
```
The actual use case code, which threw the error in my web application is:
```
class Presentation:
"""Accumulates content for a terminal."""
def __init__(self, terminal):
"""Sets the respective terminal."""
self.terminal = terminal
self.cache = {}
@property
def _direct_groups(self):
"""Yields groups this terminal is a member of."""
for gmt in GroupMemberTerminal.select().where(
GroupMemberTerminal.terminal == self.terminal):
yield gmt.group
@property
def grouplevels(self):
"""Yields group levels in a breadth-first search."""
level = frozenset(self._direct_groups)
while level:
yield level
level = frozenset(group.parent for group in level if group.parent)
@property
@cached_method()
@coerce(frozenset)
def groups(self):
"""Yields all groups in a breadth-first search."""
for level in self.grouplevels:
for group in level:
yield group
@property
def groupconfigs(self):
"""Returns a configuration for the terminal's groups."""
for index, level in enumerate(self.grouplevels):
try:
configuration, *superfluous = level_configs(level)
except ValueError:
continue
if superfluous:
raise AmbiguousConfigurationsError(level, index)
yield configuration
raise NoConfigurationFound()
@property
def configuration(self):
"""Returns the terminal's configuration."""
for configuration in Configuration.select().join(
TerminalConfiguration).where(
TerminalConfiguration.terminal == self.terminal):
return configuration
for configuration in self.groupconfigs:
return configuration
raise NoConfigurationFound()
@property
@cached_method()
@coerce(frozenset)
def menus(self):
"""Yields menus of this terminal."""
# Menus directly attached to the terminal.
yield from Menu.select().join(TerminalMenu).where(
TerminalMenu.terminal == self.terminal)
# Menus attached to groups the terminal is a member of.
yield from Menu.select().join(GroupMenu).where(
GroupMenu.group << self.groups)
@property
@cached_method()
@coerce(frozenset)
def base_charts(self):
"""Yields the terminal's base charts."""
# Charts directy attached to the terminal.
yield from BaseChart.select().join(TerminalBaseChart).where(
(BaseChart.trashed == 0)
& (TerminalBaseChart.terminal == self.terminal))
# Charts attached to groups, the terminal is a member of.
yield from BaseChart.select().join(GroupBaseChart).where(
(BaseChart.trashed == 0) & (GroupBaseChart.group << self.groups))
# Charts attached to menus of this terminal.
yield from BaseChart.select().join(MenuItemChart).join(MenuItem).where(
(BaseChart.trashed == 0) & (MenuItem.menu << self.menus))
@property
@cached_method()
@coerce(frozenset)
def charts(self):
"""Yields the terminal's charts."""
for base_chart in self.base_charts:
try:
yield base_chart.chart
except OrphanedBaseChart:
LOGGER.error('Base chart is orphaned: %s.', base_chart)
except AmbiguousBaseChart:
LOGGER.error('Base chart is ambiguous: %s.', base_chart)
@property
@cached_method()
@coerce(frozenset)
def files(self):
"""Yields the presentation's used file IDs."""
yield from self.configuration.files
for chart in self.charts:
try:
files = chart.files
except AttributeError:
continue
yield from files
def to_dom(self):
"""Returns an XML dom presentation."""
xml = dom.presentation()
xml.customer = self.terminal.customer.id
xml.tid = self.terminal.tid
xml.configuration = self.configuration.to_dom()
xml.playlist = [chart.to_dom(brief=True) for chart in self.charts]
xml.menu = [menu.to_dom() for menu in self.menus]
xml.chart = [chart.to_dom() for chart in self.charts]
return xml
def to_json(self):
"""Returns a JSON presentation."""
return {
'customer': self.terminal.customer.id,
'tid': self.terminal.tid,
'configuration': self.configuration.to_json(),
'playlist': [
chart.to_json(mode=ChartMode.BRIEF) for chart in self.charts],
'menus': [menu.to_json() for menu in self.menus],
'charts': [chart.to_json() for chart in self.charts]}
```
May support for `frozenset` be added? | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1727/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1727/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1726 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1726/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1726/comments | https://api.github.com/repos/coleifer/peewee/issues/1726/events | https://github.com/coleifer/peewee/issues/1726 | 360,437,680 | MDU6SXNzdWUzNjA0Mzc2ODA= | 1,726 | Cannot have an object initialization on __init__() | {
"login": "GabrielSalla",
"id": 15304514,
"node_id": "MDQ6VXNlcjE1MzA0NTE0",
"avatar_url": "https://avatars.githubusercontent.com/u/15304514?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/GabrielSalla",
"html_url": "https://github.com/GabrielSalla",
"followers_url": "https://api.github.com/users/GabrielSalla/followers",
"following_url": "https://api.github.com/users/GabrielSalla/following{/other_user}",
"gists_url": "https://api.github.com/users/GabrielSalla/gists{/gist_id}",
"starred_url": "https://api.github.com/users/GabrielSalla/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/GabrielSalla/subscriptions",
"organizations_url": "https://api.github.com/users/GabrielSalla/orgs",
"repos_url": "https://api.github.com/users/GabrielSalla/repos",
"events_url": "https://api.github.com/users/GabrielSalla/events{/privacy}",
"received_events_url": "https://api.github.com/users/GabrielSalla/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"No, I have no plans to add such login in 3.x. You could always make the logger a lazy-loaded property...hell that's probably a lot better anyways, right?\r\n\r\n```\r\n@property\r\ndef _logger(self):\r\n if not hasattr(self, '_logger_obj'):\r\n self._logger_obj = logging.getLogger(...)\r\n return self._logger_obj\r\n```\r\n\r\nIt's Python, so you can be creative.",
"Well, never thought about solving it this way. Smart sollution!\r\n\r\nMaybe there're more people with a similar problem, would be interesting if this solution of lazy loading an instance object was in the documentation."
] | 2018-09-14T20:06:41 | 2018-09-14T21:17:43 | 2018-09-14T21:04:53 | NONE | null | I want to criate a logger object to each one of my objects. In the 2.X versions overriding the `_prepare_instance()` to create the logger would work as in the `__init__()` method the object would not have the information yet.
Here's an example:
```python
class Alert(BaseModel):
id = peewee.PrimaryKeyField()
module = peewee.ForeignKeyField(BaseModule)
status = peewee.CharField(index=True)
level = peewee.IntegerField()
acknowledged = peewee.BooleanField(default=False)
created_at = DateTimeTZField(default=time_utils.now)
solved_at = DateTimeTZField(null=True)
class Meta:
database = database
def _prepare_instance(self, *args, **kwargs):
super(Alert, self)._prepare_instance(*args, **kwargs)
self._logger = logging.getLogger(f"({self.module.id}) Alert {self.id}")
```
If, instead of the `_prepare_instance()` method I used the `__init__()` method, the values of `self.module.id` and `self.id` would be None.
In the 3.X the `_prepare_instance()` doesn't exists anymore and looking at the source code, there's no replacement for it, these calls were just removed.
Now, if I want to create the logger object, I need to call a "setup" method manually for each object every time I create a new one or load one from the database.
Is there any plan to make it possible to "prepare the instance" automatically after it's loaded? | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1726/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1726/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1725 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1725/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1725/comments | https://api.github.com/repos/coleifer/peewee/issues/1725/events | https://github.com/coleifer/peewee/pull/1725 | 359,925,485 | MDExOlB1bGxSZXF1ZXN0MjE1MzA1ODI0 | 1,725 | Fix example/blog time formatting | {
"login": "Susensio",
"id": 11474625,
"node_id": "MDQ6VXNlcjExNDc0NjI1",
"avatar_url": "https://avatars.githubusercontent.com/u/11474625?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/Susensio",
"html_url": "https://github.com/Susensio",
"followers_url": "https://api.github.com/users/Susensio/followers",
"following_url": "https://api.github.com/users/Susensio/following{/other_user}",
"gists_url": "https://api.github.com/users/Susensio/gists{/gist_id}",
"starred_url": "https://api.github.com/users/Susensio/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/Susensio/subscriptions",
"organizations_url": "https://api.github.com/users/Susensio/orgs",
"repos_url": "https://api.github.com/users/Susensio/repos",
"events_url": "https://api.github.com/users/Susensio/events{/privacy}",
"received_events_url": "https://api.github.com/users/Susensio/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [] | 2018-09-13T14:37:47 | 2018-09-13T14:48:34 | 2018-09-13T14:48:34 | CONTRIBUTOR | null | Just a minor bug found testing your blog example, timestamp was printing `YEAR:HOUR`, fixed it to `HOUR:MIN` | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1725/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1725/timeline | null | null | false | {
"url": "https://api.github.com/repos/coleifer/peewee/pulls/1725",
"html_url": "https://github.com/coleifer/peewee/pull/1725",
"diff_url": "https://github.com/coleifer/peewee/pull/1725.diff",
"patch_url": "https://github.com/coleifer/peewee/pull/1725.patch",
"merged_at": "2018-09-13T14:48:34"
} |
https://api.github.com/repos/coleifer/peewee/issues/1724 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1724/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1724/comments | https://api.github.com/repos/coleifer/peewee/issues/1724/events | https://github.com/coleifer/peewee/pull/1724 | 359,791,849 | MDExOlB1bGxSZXF1ZXN0MjE1MjAxNDIw | 1,724 | Only validate if not backref | {
"login": "Susensio",
"id": 11474625,
"node_id": "MDQ6VXNlcjExNDc0NjI1",
"avatar_url": "https://avatars.githubusercontent.com/u/11474625?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/Susensio",
"html_url": "https://github.com/Susensio",
"followers_url": "https://api.github.com/users/Susensio/followers",
"following_url": "https://api.github.com/users/Susensio/following{/other_user}",
"gists_url": "https://api.github.com/users/Susensio/gists{/gist_id}",
"starred_url": "https://api.github.com/users/Susensio/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/Susensio/subscriptions",
"organizations_url": "https://api.github.com/users/Susensio/orgs",
"repos_url": "https://api.github.com/users/Susensio/repos",
"events_url": "https://api.github.com/users/Susensio/events{/privacy}",
"received_events_url": "https://api.github.com/users/Susensio/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"Thank you"
] | 2018-09-13T08:23:45 | 2018-09-13T14:27:55 | 2018-09-13T14:27:49 | CONTRIBUTOR | null | This validation was throwing an exception when creating the backref, because it has a through_model and also receives on_delete and on_update values.
#1719 | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1724/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1724/timeline | null | null | false | {
"url": "https://api.github.com/repos/coleifer/peewee/pulls/1724",
"html_url": "https://github.com/coleifer/peewee/pull/1724",
"diff_url": "https://github.com/coleifer/peewee/pull/1724.diff",
"patch_url": "https://github.com/coleifer/peewee/pull/1724.patch",
"merged_at": "2018-09-13T14:27:48"
} |
https://api.github.com/repos/coleifer/peewee/issues/1723 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1723/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1723/comments | https://api.github.com/repos/coleifer/peewee/issues/1723/events | https://github.com/coleifer/peewee/issues/1723 | 359,494,859 | MDU6SXNzdWUzNTk0OTQ4NTk= | 1,723 | Peewee throw exception on 2nd time select query | {
"login": "Maheshkumar094",
"id": 39484115,
"node_id": "MDQ6VXNlcjM5NDg0MTE1",
"avatar_url": "https://avatars.githubusercontent.com/u/39484115?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/Maheshkumar094",
"html_url": "https://github.com/Maheshkumar094",
"followers_url": "https://api.github.com/users/Maheshkumar094/followers",
"following_url": "https://api.github.com/users/Maheshkumar094/following{/other_user}",
"gists_url": "https://api.github.com/users/Maheshkumar094/gists{/gist_id}",
"starred_url": "https://api.github.com/users/Maheshkumar094/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/Maheshkumar094/subscriptions",
"organizations_url": "https://api.github.com/users/Maheshkumar094/orgs",
"repos_url": "https://api.github.com/users/Maheshkumar094/repos",
"events_url": "https://api.github.com/users/Maheshkumar094/events{/privacy}",
"received_events_url": "https://api.github.com/users/Maheshkumar094/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"PLEASE FORMAT YOUR CODE.",
"Coleifer it is formated in my code base I copy past some part it that why its look unformatted. Ok I will comment code in more formatted way.",
"FUCK MAN, CLICK \"Styling with Markdown is supported\" -- it will show you how to highlight your code. There's also a handy \"<>\" toolbar button on the comment editor.",
"```\r\nclass Usr(BaseModel):\r\n created_at = IntegerField(null=True)\r\n created_at1 = DateTimeField(null=True)\r\n created_by = IntegerField(null=True)\r\n created_by1 = IntegerField(null=True)\r\n email = CharField()\r\n is_email_verified = BooleanField(null=True)\r\n is_test = BooleanField(null=True)\r\n last_modified_at = DateTimeField(null=True)\r\n last_modified_by = IntegerField(null=True)\r\n mobile = CharField()\r\n name = CharField()\r\n password = CharField()\r\n username = CharField()\r\n\r\n\r\n class Meta:\r\n table_name = 'usr'\r\n schema = 'public'\r\n```\r\n\r\n\r\n```\r\nclass Passenger(BaseModel):\r\n created_at = DateTimeField(null=True)\r\n created_by = IntegerField(null=True)\r\n flexi_time_window = IntegerField(null=True)\r\n home_address = CharField(null=True)\r\n home_fav_time = DateTimeField(null=True)\r\n home_loc = UnknownField(null=True) # USER-DEFINED\r\n is_time_flexible = BooleanField(null=True)\r\n last_modified_at = DateTimeField(null=True)\r\n last_modified_by = IntegerField(null=True)\r\n name = CharField()\r\n non_refundable_credit = DecimalField(null=True)\r\n office_address = CharField(null=True)\r\n office_fav_time = DateTimeField(null=True)\r\n office_loc = UnknownField(null=True) # USER-DEFINED\r\n refundable_credit = DecimalField(null=True)\r\n total_credit_balance = DecimalField(null=True)\r\n #user = ForeignKeyField(column_name='user_id', field='id', model=Usr)\r\n user = ForeignKeyField(column_name='user_id', field='id', model=Usr)\r\n\r\n class Meta:\r\n table_name = 'passenger'\r\n schema = 'public'\r\n\r\n\r\n```\r\n\r\n\r\n\r\n```\r\ndef is_usr_valid2(email):\r\n try:\r\n #sub = model.Usr.get(model.Usr.email == email)\r\n sub = model.Usr.select().where(model.Usr.email == email)\r\n record = model.Passenger.select().where((model.Passenger.user ==sub))\r\n print 'sql ={}'.format(record.sql())\r\n print list(record.dicts())\r\n print \"===========User Login Detail ============\"\r\n print list(record.dicts())[0]['id']\r\n #print (\"id = {} Name ={} \\n Email = {} \".format(record.id,record.name, record.email))\r\n cnf.statuscode = cnf.ok\r\n cnf.is_error = False\r\n return record\r\n except Exception as e:\r\n print(\"Error During fetching user detail \\n {}\".format(e))\r\n cnf.is_error = True\r\n cnf.statuscode = cnf.Internal_server_Error\r\n tb.print_exc()\r\n #raise\r\n return None\r\n\r\nif __name__ == '__main__':\r\n #================== first call =============\r\n print is_usr_valid2(\"[email protected]\")\r\n #=================== second call ===========\r\n print is_usr_valid2(\"[email protected]\")\r\n```\r\n\r\n> Above code work fine for time for the second call it got an exception\r\n> on first call it form correct query\r\n\r\n \r\n**('SELECT \"t1\".\"id\", \"t1\".\"created_at\", \"t1\".\"created_by\", \"t1\".\"flexi_time_window\", \"t1\".\"home_address\", \"t1\".\"home_fav_time\", \"t1\".\"is_time_flexible\", \"t1\".\"last_modified_at\", \"t1\".\"last_modified_by\", \"t1\".\"name\", \"t1\".\"non_refundable_credit\", \"t1\".\"office_address\", \"t1\".\"office_fav_time\", \"t1\".\"refundable_credit\", \"t1\".\"total_credit_balance\", \"t1\".\"user_id\" FROM \"public\".\"passenger\" AS \"t1\" WHERE (\"t1\".\"user_id\" = (SELECT \"t2\".\"id\" FROM \"public\".\"usr\" AS \"t2\" WHERE (\"t2\".\"email\" = %s)))', [u'[email protected]'])**\r\n\r\n**Query Result** \r\n\r\n[{'home_fav_time': None, 'home_address': None, 'name': u'Antar ', 'is_time_flexible': None, 'office_address': None, 'created_at': datetime.datetime(2018, 6, 8, 10, 23, 33, 895096, tzinfo=psycopg2.tz.FixedOffsetTimezone(offset=0, name=None)), 'refundable_credit': Decimal('52.000000'), 'created_by': None, 'office_fav_time': None, 'flexi_time_window': None, 'last_modified_at': datetime.datetime(2018, 6, 8, 10, 23, 33, 895096, tzinfo=psycopg2.tz.FixedOffsetTimezone(offset=0, name=None)), 'non_refundable_credit': Decimal('0.000000'), 'total_credit_balance': Decimal('52.000000'), 'last_modified_by': None, 'id': 61, 'user': 129}]\r\n\r\non second call it generates a query\r\n\r\n**('SELECT \"t1\".\"id\", \"t1\".\"created_at\", \"t1\".\"created_by\", \"t1\".\"flexi_time_window\", \"t1\".\"home_address\", \"t1\".\"home_fav_time\", \"t1\".\"is_time_flexible\", \"t1\".\"last_modified_at\", \"t1\".\"last_modified_by\", \"t1\".\"name\", \"t1\".\"non_refundable_credit\", \"t1\".\"office_address\", \"t1\".\"office_fav_time\", \"t1\".\"refundable_credit\", \"t1\".\"total_credit_balance\", \"t1\".\"user_id\" FROM \"public\".\"passenger\" AS \"t1\" WHERE %s', [False])**\r\n\r\n**I can't understand how this where condition generated \"WHERE %s', [False]\" come**\r\n\r\n@coleifer I hope Now the code look bit formatted",
"My guess is you're overwriting models.Passenger.user somewhere."
] | 2018-09-12T14:00:10 | 2018-09-12T20:04:53 | 2018-09-12T18:03:33 | NONE | null | ```
class Usr(BaseModel):
created_at = IntegerField(null=True)
created_at1 = DateTimeField(null=True)
created_by = IntegerField(null=True)
created_by1 = IntegerField(null=True)
email = CharField()
is_email_verified = BooleanField(null=True)
is_test = BooleanField(null=True)
last_modified_at = DateTimeField(null=True)
last_modified_by = IntegerField(null=True)
mobile = CharField()
name = CharField()
password = CharField()
username = CharField()
class Meta:
table_name = 'usr'
schema = 'public'
```
```
class Passenger(BaseModel):
created_at = DateTimeField(null=True)
created_by = IntegerField(null=True)
flexi_time_window = IntegerField(null=True)
home_address = CharField(null=True)
home_fav_time = DateTimeField(null=True)
home_loc = UnknownField(null=True) # USER-DEFINED
is_time_flexible = BooleanField(null=True)
last_modified_at = DateTimeField(null=True)
last_modified_by = IntegerField(null=True)
name = CharField()
non_refundable_credit = DecimalField(null=True)
office_address = CharField(null=True)
office_fav_time = DateTimeField(null=True)
office_loc = UnknownField(null=True) # USER-DEFINED
refundable_credit = DecimalField(null=True)
total_credit_balance = DecimalField(null=True)
#user = ForeignKeyField(column_name='user_id', field='id', model=Usr)
user = ForeignKeyField(column_name='user_id', field='id', model=Usr)
class Meta:
table_name = 'passenger'
schema = 'public'
```
```
def is_usr_valid2(email):
try:
#sub = model.Usr.get(model.Usr.email == email)
sub = model.Usr.select().where(model.Usr.email == email)
record = model.Passenger.select().where((model.Passenger.user ==sub))
print 'sql ={}'.format(record.sql())
print list(record.dicts())
print "===========User Login Detail ============"
print list(record.dicts())[0]['id']
#print ("id = {} Name ={} \n Email = {} ".format(record.id,record.name, record.email))
cnf.statuscode = cnf.ok
cnf.is_error = False
return record
except Exception as e:
print("Error During fetching user detail \n {}".format(e))
cnf.is_error = True
cnf.statuscode = cnf.Internal_server_Error
tb.print_exc()
#raise
return None
if __name__ == '__main__':
#================== first call =============
print is_usr_valid2("[email protected]")
#=================== second call ===========
print is_usr_valid2("[email protected]")
```
> Above code work fine for time for the second call it got an exception
> on first call it form correct query
**('SELECT "t1"."id", "t1"."created_at", "t1"."created_by", "t1"."flexi_time_window", "t1"."home_address", "t1"."home_fav_time", "t1"."is_time_flexible", "t1"."last_modified_at", "t1"."last_modified_by", "t1"."name", "t1"."non_refundable_credit", "t1"."office_address", "t1"."office_fav_time", "t1"."refundable_credit", "t1"."total_credit_balance", "t1"."user_id" FROM "public"."passenger" AS "t1" WHERE ("t1"."user_id" = (SELECT "t2"."id" FROM "public"."usr" AS "t2" WHERE ("t2"."email" = %s)))', [u'[email protected]'])**
**Query Result**
[{'home_fav_time': None, 'home_address': None, 'name': u'Antar ', 'is_time_flexible': None, 'office_address': None, 'created_at': datetime.datetime(2018, 6, 8, 10, 23, 33, 895096, tzinfo=psycopg2.tz.FixedOffsetTimezone(offset=0, name=None)), 'refundable_credit': Decimal('52.000000'), 'created_by': None, 'office_fav_time': None, 'flexi_time_window': None, 'last_modified_at': datetime.datetime(2018, 6, 8, 10, 23, 33, 895096, tzinfo=psycopg2.tz.FixedOffsetTimezone(offset=0, name=None)), 'non_refundable_credit': Decimal('0.000000'), 'total_credit_balance': Decimal('52.000000'), 'last_modified_by': None, 'id': 61, 'user': 129}]
on second call it generates a query
**('SELECT "t1"."id", "t1"."created_at", "t1"."created_by", "t1"."flexi_time_window", "t1"."home_address", "t1"."home_fav_time", "t1"."is_time_flexible", "t1"."last_modified_at", "t1"."last_modified_by", "t1"."name", "t1"."non_refundable_credit", "t1"."office_address", "t1"."office_fav_time", "t1"."refundable_credit", "t1"."total_credit_balance", "t1"."user_id" FROM "public"."passenger" AS "t1" WHERE %s', [False])**
**I can't understand how this where condition generated "WHERE %s', [False]" come**
@coleifer I hope Now the code look bit formatted | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1723/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1723/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1722 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1722/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1722/comments | https://api.github.com/repos/coleifer/peewee/issues/1722/events | https://github.com/coleifer/peewee/issues/1722 | 359,360,213 | MDU6SXNzdWUzNTkzNjAyMTM= | 1,722 | Please support python 3 abstract methods | {
"login": "fluffy-critter",
"id": 347162,
"node_id": "MDQ6VXNlcjM0NzE2Mg==",
"avatar_url": "https://avatars.githubusercontent.com/u/347162?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/fluffy-critter",
"html_url": "https://github.com/fluffy-critter",
"followers_url": "https://api.github.com/users/fluffy-critter/followers",
"following_url": "https://api.github.com/users/fluffy-critter/following{/other_user}",
"gists_url": "https://api.github.com/users/fluffy-critter/gists{/gist_id}",
"starred_url": "https://api.github.com/users/fluffy-critter/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/fluffy-critter/subscriptions",
"organizations_url": "https://api.github.com/users/fluffy-critter/orgs",
"repos_url": "https://api.github.com/users/fluffy-critter/repos",
"events_url": "https://api.github.com/users/fluffy-critter/events{/privacy}",
"received_events_url": "https://api.github.com/users/fluffy-critter/received_events",
"type": "User",
"site_admin": false
} | [] | closed | true | null | [] | null | [
"bro-bro...Python is a dynamic language. Peewee uses this dynamism to provide such nice (if I do say so myself) APIs. There will be no ABCs.",
"Hi, I'm rather disappointed in this response for a number of reasons.\r\n\r\nAt the very least I would like to be able to run pylint against peewee without getting a bunch of spurious E1111 notifications, and there are many mechanisms that peewee could use to provide that ability. ABCs were the most readily-obvious ones but there are other approaches as well.\r\n\r\nI also don't really care for the condescending tone of your response. I realize that peewee is a volunteer effort that you do for your own needs but it's also part of a greater ecosystem.\r\n\r\nAlso, I'm not a bro."
] | 2018-09-12T08:02:24 | 2018-09-12T20:12:11 | 2018-09-12T13:51:21 | NONE | off-topic | Since Python 3.4, there has been a mechanism for declaring abstract base classes and methods thereof, from the [`abc` module](https://docs.python.org/3/library/abc.html). As of Python 3.7, pylint pretty much requires its use; for example, the line:
self._query = model.Entry.select().where(self._where)
results in the pylint error:
publ/view.py:89:8: E1111: Assigning to function call which doesn't return (assignment-from-no-return)
As a temporary measure I can simply disable that warning from pylint, but going forward it would be great if peewee were to use `abc.abstractmethod` and `abc.ABC` to suppress these errors and provide abstract base classes in a more declarative, linter-friendly way.
| {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1722/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1722/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1721 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1721/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1721/comments | https://api.github.com/repos/coleifer/peewee/issues/1721/events | https://github.com/coleifer/peewee/issues/1721 | 359,071,556 | MDU6SXNzdWUzNTkwNzE1NTY= | 1,721 | Slow performance of execute_sql() | {
"login": "ssrebelious",
"id": 2326764,
"node_id": "MDQ6VXNlcjIzMjY3NjQ=",
"avatar_url": "https://avatars.githubusercontent.com/u/2326764?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/ssrebelious",
"html_url": "https://github.com/ssrebelious",
"followers_url": "https://api.github.com/users/ssrebelious/followers",
"following_url": "https://api.github.com/users/ssrebelious/following{/other_user}",
"gists_url": "https://api.github.com/users/ssrebelious/gists{/gist_id}",
"starred_url": "https://api.github.com/users/ssrebelious/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/ssrebelious/subscriptions",
"organizations_url": "https://api.github.com/users/ssrebelious/orgs",
"repos_url": "https://api.github.com/users/ssrebelious/repos",
"events_url": "https://api.github.com/users/ssrebelious/events{/privacy}",
"received_events_url": "https://api.github.com/users/ssrebelious/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"Since you're literally just using `execute_sql()` and not using any of the query-builder APIs, you should note that Peewee is just using `psycopg2` the Python driver.\r\n\r\nI'd suggest that you might raise this issue over on `psycopg2` since I don't think this reflects an actual Peewee performance issue.",
"Your logic is legit, but it seems that there is no performance issue on the `psycopg2` side.\r\n```python\r\nstart_time = datetime.now()\r\nconn = psycopg2.connect(**kwargs)\r\nwith conn.cursor() as cursor:\r\n cursor.execute(\r\n ''' SELECT id, name, ts_rank(vector, query) AS rank \r\n FROM element, to_tsvector('russian', name) vector, \r\n to_tsquery('russian', %s) query \r\n WHERE to_tsvector('russian', name) @@ query \r\n ORDER BY rank DESC \r\n LIMIT 20''', \r\n ('транспортировка:* & эмульсия:* & 1',)\r\n )\r\n result = cursor.fetchall()\r\nconn.close()\r\nfinish_time = datetime.now() - start_time\r\nprint(finish_time)\r\n```\r\ngives me `0:00:00.01233`",
"But the code is literally the same...\r\n\r\n```python\r\n def execute_sql(self, sql, params=None, commit=SENTINEL):\r\n logger.debug((sql, params))\r\n if commit is SENTINEL:\r\n if self.in_transaction():\r\n commit = False\r\n elif self.commit_select:\r\n commit = True\r\n else:\r\n commit = not sql[:6].lower().startswith('select')\r\n\r\n with __exception_wrapper__:\r\n cursor = self.cursor(commit)\r\n try:\r\n cursor.execute(sql, params or ())\r\n except Exception:\r\n if self.autorollback and not self.in_transaction():\r\n self.rollback()\r\n raise\r\n else:\r\n if commit and not self.in_transaction():\r\n self.commit()\r\n return cursor\r\n```",
"You could try `.execute_sql(..., commit=False)` -- and this is Peewee 3.x, but you should be able to figure out the equivalent in 2.10.",
"Thanks! That dropped timings to 0.1 s, but it is still 10 times slower than pure `psycopg2` request. ",
"*shrug*? May you can profile it and paste some output? I don't see anything obvious, though.",
"> it is still 10 times slower than pure `psycopg2` request.\r\n\r\nI had an issue in my testing setup so `peewee` and `psycopg2` were connected to the different databases, that was the reason for the time difference mentioned in my last post. Sorry for bothering. And thanks for the cool ORM :)\r\n",
"Shit I didn't even think to ask. Well I'm glad peewees not 10x slower. I was slightly worried bc I didn't have a good way to explain that."
] | 2018-09-11T14:23:43 | 2018-09-13T13:14:17 | 2018-09-11T14:33:26 | NONE | null | I have a table `Element` in PostgreSQL database that has over 60 000 records in it and I need to perform a full-text-search for the column `name`.
```sql
CREATE TABLE public."element" (
id serial NOT NULL,
"name" varchar(400) NOT NULL,
CONSTRAINT element_pkey PRIMARY KEY (id)
);
CREATE INDEX element_name_tsvector_idx ON public.element
USING gin (to_tsvector('russian'::regconfig, (name)::text)); -- this index speeds up full-text-search from 1.5 s to 2 ms
```
Following query in database console is executed in 2 ms when it uses the index above and in 1.5 s when there is no such index.
```sql
SELECT id, name, ts_rank(vector, query) AS rank
FROM element, to_tsvector('russian', name) vector,
to_tsquery('russian', 'транспортировка:* & эмульсия:* & 1') query
WHERE to_tsvector('russian', name) @@ query
ORDER BY rank desc
LIMIT 20
```
I want to port this query to peewee-enabled app using straight-forward approach like that.
```python
from datetime import datetime
from peewee import PostgresqlDatabase, Model
pg_db = PostgresqlDatabase(**connection_kwargs)
FULL_TEXT_SEARCH = '''
SELECT id, {search_field}, ts_rank(vector, query) AS rank
FROM {table_name}, to_tsvector('russian', {search_field}) vector,
to_tsquery('russian', %s) query
WHERE to_tsvector('russian', {search_field}) @@ query
ORDER BY rank DESC
LIMIT 20
'''
class Element(Model):
name = CharField()
class Meta:
database = pg_db
@classmethod
def full_text_search(cls, column_name: str, query_string: str):
kwargs = dict(
table_name=cls._meta.db_table,
search_field=column_name
)
query = FULL_TEXT_SEARCH.format(**kwargs)
cursor = cls._meta.database.execute_sql(
query,
(query_string,)
)
result = cursor.fetchall()
cursor.close()
return result
```
Unfortunately, `full_text_search()` method takes abysmal 1.7 seconds to execute (without the index it takes 3.5 seconds), of which only 2 ms is spent on Postgres side. It is obvious and a profiler says that the most of the time is used by `execute_sql`. Is there something I can do to speed up the process? I'm using peewee 2.10.2, but 3.7 seems to have the same execution time. | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1721/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1721/timeline | null | completed | null | null |
https://api.github.com/repos/coleifer/peewee/issues/1720 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1720/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1720/comments | https://api.github.com/repos/coleifer/peewee/issues/1720/events | https://github.com/coleifer/peewee/pull/1720 | 358,850,003 | MDExOlB1bGxSZXF1ZXN0MjE0NDg2MTIy | 1,720 | Connect to DB only if not connected already | {
"login": "mekanix",
"id": 610855,
"node_id": "MDQ6VXNlcjYxMDg1NQ==",
"avatar_url": "https://avatars.githubusercontent.com/u/610855?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/mekanix",
"html_url": "https://github.com/mekanix",
"followers_url": "https://api.github.com/users/mekanix/followers",
"following_url": "https://api.github.com/users/mekanix/following{/other_user}",
"gists_url": "https://api.github.com/users/mekanix/gists{/gist_id}",
"starred_url": "https://api.github.com/users/mekanix/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/mekanix/subscriptions",
"organizations_url": "https://api.github.com/users/mekanix/orgs",
"repos_url": "https://api.github.com/users/mekanix/repos",
"events_url": "https://api.github.com/users/mekanix/events{/privacy}",
"received_events_url": "https://api.github.com/users/mekanix/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"I'll pass, because in my opinion an unclosed connection is a bug and this could lead to sloppy programming. You are welcome to subclass this in your own app and override the method as you like, however.",
"Maybe I wasn't clear enough, so I apologize. If you use FlaskDB with `sqlite:///:memory:`, there is no test you can write that won't break with mentioned error, so if there is a bug, it's on PeeWee side. Other DBs are fine and don't throw an error. Subclassing is OK, but I think it would be better if it would work without the subclass. I can write the simplest showcase, if needed. Also, if you think finding why multiple connections are opened, that's fine too, but I wonder why the same check is OK in `close_db` but isn't in `connect_db`?",
"> If you use FlaskDB with sqlite:///:memory:\r\n\r\nWell, yes -- of course this will not work because every time you connect or close the connection, the data goes away. If you want to use an in-memory sqlite database, then obviously FlaskDB won't work for you.\r\n\r\nThe check is not present in connect_db() because an already-opened connection at that point indicates a dangling / unclosed connection from somewhere in the app.",
"OK, I didn't know one should not use FlaskDB with :memory: for tests. What would be the appropriate way to have sqlite in dev, sqlite:///:memory: in test and postgresql in production? As I already have different config class for each of them, should I use `SqliteDatabase` and `PostgresqlDatabase` classes in config? I did try closing DB in tearDown, but I still get this error. So, to put it short, how should I use sqlite:///:memory: for tests with pytest or nose?"
] | 2018-09-11T01:14:15 | 2018-09-11T14:55:48 | 2018-09-11T14:00:52 | NONE | null | When testing Flask apps, failure is "peewee.OperationalError: Connection already opened." I used the same logic inside connect_db as the one used in close_db. | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1720/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1720/timeline | null | null | false | {
"url": "https://api.github.com/repos/coleifer/peewee/pulls/1720",
"html_url": "https://github.com/coleifer/peewee/pull/1720",
"diff_url": "https://github.com/coleifer/peewee/pull/1720.diff",
"patch_url": "https://github.com/coleifer/peewee/pull/1720.patch",
"merged_at": null
} |
https://api.github.com/repos/coleifer/peewee/issues/1719 | https://api.github.com/repos/coleifer/peewee | https://api.github.com/repos/coleifer/peewee/issues/1719/labels{/name} | https://api.github.com/repos/coleifer/peewee/issues/1719/comments | https://api.github.com/repos/coleifer/peewee/issues/1719/events | https://github.com/coleifer/peewee/pull/1719 | 358,663,801 | MDExOlB1bGxSZXF1ZXN0MjE0MzQ1MjA4 | 1,719 | Feature/manytomanyfield-ondelete | {
"login": "Susensio",
"id": 11474625,
"node_id": "MDQ6VXNlcjExNDc0NjI1",
"avatar_url": "https://avatars.githubusercontent.com/u/11474625?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/Susensio",
"html_url": "https://github.com/Susensio",
"followers_url": "https://api.github.com/users/Susensio/followers",
"following_url": "https://api.github.com/users/Susensio/following{/other_user}",
"gists_url": "https://api.github.com/users/Susensio/gists{/gist_id}",
"starred_url": "https://api.github.com/users/Susensio/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/Susensio/subscriptions",
"organizations_url": "https://api.github.com/users/Susensio/orgs",
"repos_url": "https://api.github.com/users/Susensio/repos",
"events_url": "https://api.github.com/users/Susensio/events{/privacy}",
"received_events_url": "https://api.github.com/users/Susensio/received_events",
"type": "User",
"site_admin": false
} | [] | closed | false | null | [] | null | [
"I've implemented this with additional support for on_update, plus some additional validation. Thanks."
] | 2018-09-10T15:00:47 | 2018-09-10T15:32:19 | 2018-09-10T15:32:19 | CONTRIBUTOR | null | #1718
IDK if I'm creating the pull request correctly. I have run tests and changes do not throw any errors. | {
"url": "https://api.github.com/repos/coleifer/peewee/issues/1719/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} | https://api.github.com/repos/coleifer/peewee/issues/1719/timeline | null | null | false | {
"url": "https://api.github.com/repos/coleifer/peewee/pulls/1719",
"html_url": "https://github.com/coleifer/peewee/pull/1719",
"diff_url": "https://github.com/coleifer/peewee/pull/1719.diff",
"patch_url": "https://github.com/coleifer/peewee/pull/1719.patch",
"merged_at": null
} |
Subsets and Splits