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/914
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/914/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/914/comments
https://api.github.com/repos/coleifer/peewee/issues/914/events
https://github.com/coleifer/peewee/issues/914
149,680,922
MDU6SXNzdWUxNDk2ODA5MjI=
914
Sqlite datetime with timezone is not converted into datetime
{ "login": "goir", "id": 586209, "node_id": "MDQ6VXNlcjU4NjIwOQ==", "avatar_url": "https://avatars.githubusercontent.com/u/586209?v=4", "gravatar_id": "", "url": "https://api.github.com/users/goir", "html_url": "https://github.com/goir", "followers_url": "https://api.github.com/users/goir/followers", "following_url": "https://api.github.com/users/goir/following{/other_user}", "gists_url": "https://api.github.com/users/goir/gists{/gist_id}", "starred_url": "https://api.github.com/users/goir/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/goir/subscriptions", "organizations_url": "https://api.github.com/users/goir/orgs", "repos_url": "https://api.github.com/users/goir/repos", "events_url": "https://api.github.com/users/goir/events{/privacy}", "received_events_url": "https://api.github.com/users/goir/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "SQLite will store timezone info, but I'm not sure what facilities it provides for sorting when you've got a mixture of timezones (without involving various date functions). You'll probably want to read up on it here: https://www.sqlite.org/lang_datefunc.html -- It might be more convenient to convert to UTC in your application before passing ot the database.\n\nThat said, it does seem like peewee should handle the timezone. For now you can subclass the `DateTimeField` and override the formats class attribute.\n\nI'll look into a fix.\n", "I agree, its not really an issue, more a feature request to have a timezone aware datetime field.\n", "I don't believe I will implement this. If you want to register your own adapter at the driver level, or if you want to implement your own TZ-aware sqlite datetime-field, then I think that'd be the best course. A general purpose solution, though, I'm going to pass on.\n" ]
2016-04-20T07:16:21
2016-05-30T23:28:39
2016-05-30T23:28:39
NONE
null
If you store a timezone aware datetime in sqlite the selected value is a unicode and not a datetime object. ``` import datetime import pytz from peewee import SqliteDatabase, PrimaryKeyField, DateTimeField, Model db = SqliteDatabase('test.db') class ModelA(Model): id = PrimaryKeyField() date = DateTimeField() class Meta(object): database = db ModelA.create_table(True) ModelA.create(date=datetime.datetime.now(pytz.UTC)) ModelA.create(date=datetime.datetime.now()) for a in ModelA.select(): print a.date, type(a.date) ``` which returns ``` 2016-04-20 07:06:18.021696+00:00 <type 'unicode'> 2016-04-20 09:06:18.420155 <type 'datetime.datetime'> ``` the unicode should be a datetime object with timezone set.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/914/reactions", "total_count": 2, "+1": 2, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/914/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/913
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/913/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/913/comments
https://api.github.com/repos/coleifer/peewee/issues/913/events
https://github.com/coleifer/peewee/issues/913
149,336,398
MDU6SXNzdWUxNDkzMzYzOTg=
913
Genarated query problem
{ "login": "ck196", "id": 1131215, "node_id": "MDQ6VXNlcjExMzEyMTU=", "avatar_url": "https://avatars.githubusercontent.com/u/1131215?v=4", "gravatar_id": "", "url": "https://api.github.com/users/ck196", "html_url": "https://github.com/ck196", "followers_url": "https://api.github.com/users/ck196/followers", "following_url": "https://api.github.com/users/ck196/following{/other_user}", "gists_url": "https://api.github.com/users/ck196/gists{/gist_id}", "starred_url": "https://api.github.com/users/ck196/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/ck196/subscriptions", "organizations_url": "https://api.github.com/users/ck196/orgs", "repos_url": "https://api.github.com/users/ck196/repos", "events_url": "https://api.github.com/users/ck196/events{/privacy}", "received_events_url": "https://api.github.com/users/ck196/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Please fix the formatting of code.\n", "Sorry, i've updated code formatting.\n", "To fix this I believe if you explicitly select the Video ID column you'll be set:\n\n``` python\nvideo = Video.select(Video.id).where(Video.name == 'v5.mp4')\nquery = Relationship.delete().where(Relationship.video == video)\nprint query\n```\n\nOutputs:\n\n``` sql\nDELETE FROM \"relationship\" \nWHERE (\"video_id\" = (\n SELECT \"t1\".\"id\" \n FROM \"video\" AS t1 \n WHERE (\"t1\".\"name\" = ?) \n ORDER BY \"t1\".\"add_date\" DESC\n))\n```\n\nIf you've already got the query from somewhere else and want to modify the SELECT clause, you can do:\n\n``` python\nquery = Relationship.delete().where(Relationship.video == video.select(Video.id))\n```\n\n---\n\nAn unrelated suggestion:\n\nNever ever ever specify a default ordering for your models. It's a code smell and I regret building it into Peewee's API (the idea comes from Django originally, and the Django community seems to feel the same way about it). If you want a default ordering that's easily accessible, just do something like:\n\n``` python\nclass Video(BaseModel):\n # ... fields ...\n\n @classmethod\n def all(cls):\n return cls.select().order_by(cls.add_date.desc())\n\n# ------ elsewhere in your code ------ #\n\nvideos = Video.all()\n```\n" ]
2016-04-19T03:16:08
2016-04-23T02:34:00
2016-04-23T02:33:18
NONE
null
I do deleted query on Relationship table ` query = Relationship.delete().where(Relationship.video == video) ` <class 'libs.basemodel.Relationship'> DELETE FROM "relationship" WHERE ("video_id" = (SELECT "t2"."id" FROM "video" AS t1 WHERE ("t1"."name" = ?) ORDER BY "t1"."add_date" DESC)) [u'v5.mp4'] Problem: OperationalError: no such column: t2.id My models very simple: ``` class BaseModel(Model): class Meta: database = database class User(BaseModel): username` = CharField(unique=True) password = CharField() email = CharField() join_date = DateTimeField() class Meta: order_by = ('username',) class Relationship(BaseModel): video = ForeignKeyField(User, related_name='relationships') to_user = ForeignKeyField(User, related_name='related_to') class Meta: indexes = ( # Specify a unique multi-column index on from/to-user. (('video', 'to_user'), True), ) class Video(BaseModel): name = CharField(unique=True) width = IntegerField() height = IntegerField() step = IntegerField() frame_count = IntegerField() add_date = DateTimeField() class Meta: order_by = ('-add_date',) ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/913/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/913/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/912
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/912/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/912/comments
https://api.github.com/repos/coleifer/peewee/issues/912/events
https://github.com/coleifer/peewee/issues/912
149,105,893
MDU6SXNzdWUxNDkxMDU4OTM=
912
Please support cockroachdb
{ "login": "jet10000", "id": 2258120, "node_id": "MDQ6VXNlcjIyNTgxMjA=", "avatar_url": "https://avatars.githubusercontent.com/u/2258120?v=4", "gravatar_id": "", "url": "https://api.github.com/users/jet10000", "html_url": "https://github.com/jet10000", "followers_url": "https://api.github.com/users/jet10000/followers", "following_url": "https://api.github.com/users/jet10000/following{/other_user}", "gists_url": "https://api.github.com/users/jet10000/gists{/gist_id}", "starred_url": "https://api.github.com/users/jet10000/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/jet10000/subscriptions", "organizations_url": "https://api.github.com/users/jet10000/orgs", "repos_url": "https://api.github.com/users/jet10000/repos", "events_url": "https://api.github.com/users/jet10000/events{/privacy}", "received_events_url": "https://api.github.com/users/jet10000/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Peewee should work with any Python DB-API 2.0 driver. It looks like work has started on adding one for cockroachdb:\n\nhttps://github.com/cockroachdb/cockroach-python/pull/12\n\nAfter that, follow the instructions here to integrate with Peewee:\n\nhttp://docs.peewee-orm.com/en/latest/peewee/database.html#adding-a-new-database-driver\n" ]
2016-04-18T10:07:37
2016-04-19T18:20:11
2016-04-19T18:20:11
NONE
null
https://www.cockroachlabs.com/
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/912/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/912/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/911
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/911/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/911/comments
https://api.github.com/repos/coleifer/peewee/issues/911/events
https://github.com/coleifer/peewee/pull/911
147,836,704
MDExOlB1bGxSZXF1ZXN0NjYyMDU5Nzg=
911
Change description of options in Using class docs
{ "login": "ahessert", "id": 10226899, "node_id": "MDQ6VXNlcjEwMjI2ODk5", "avatar_url": "https://avatars.githubusercontent.com/u/10226899?v=4", "gravatar_id": "", "url": "https://api.github.com/users/ahessert", "html_url": "https://github.com/ahessert", "followers_url": "https://api.github.com/users/ahessert/followers", "following_url": "https://api.github.com/users/ahessert/following{/other_user}", "gists_url": "https://api.github.com/users/ahessert/gists{/gist_id}", "starred_url": "https://api.github.com/users/ahessert/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/ahessert/subscriptions", "organizations_url": "https://api.github.com/users/ahessert/orgs", "repos_url": "https://api.github.com/users/ahessert/repos", "events_url": "https://api.github.com/users/ahessert/events{/privacy}", "received_events_url": "https://api.github.com/users/ahessert/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Thanks!\n" ]
2016-04-12T18:34:46
2016-04-12T21:35:41
2016-04-12T21:35:33
CONTRIBUTOR
null
Previous description implied that the default for the "with_transaction" kwarg was False, while the default is True. Developers must specify "with_transaction=False" if they don't want to use a transaction block with the Using class context.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/911/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/911/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/911", "html_url": "https://github.com/coleifer/peewee/pull/911", "diff_url": "https://github.com/coleifer/peewee/pull/911.diff", "patch_url": "https://github.com/coleifer/peewee/pull/911.patch", "merged_at": "2016-04-12T21:35:33" }
https://api.github.com/repos/coleifer/peewee/issues/910
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/910/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/910/comments
https://api.github.com/repos/coleifer/peewee/issues/910/events
https://github.com/coleifer/peewee/issues/910
147,648,191
MDU6SXNzdWUxNDc2NDgxOTE=
910
cache result?
{ "login": "daoiqi", "id": 2141872, "node_id": "MDQ6VXNlcjIxNDE4NzI=", "avatar_url": "https://avatars.githubusercontent.com/u/2141872?v=4", "gravatar_id": "", "url": "https://api.github.com/users/daoiqi", "html_url": "https://github.com/daoiqi", "followers_url": "https://api.github.com/users/daoiqi/followers", "following_url": "https://api.github.com/users/daoiqi/following{/other_user}", "gists_url": "https://api.github.com/users/daoiqi/gists{/gist_id}", "starred_url": "https://api.github.com/users/daoiqi/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/daoiqi/subscriptions", "organizations_url": "https://api.github.com/users/daoiqi/orgs", "repos_url": "https://api.github.com/users/daoiqi/repos", "events_url": "https://api.github.com/users/daoiqi/events{/privacy}", "received_events_url": "https://api.github.com/users/daoiqi/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Yes, try wrapping your select in an atomic block:\n\n``` python\nwith database.atomic():\n a = TVm.select()...\n```\n", "``` python\nwhile True:\n uuid = '8d443fb7-3e30-4149-bb32-89ee5532eddc'\n a = TVm.select().where(\n TVm.uuid == uuid)\n for x in a:\n print x.createTime, x.mem\n database.commit() # it will get realtime data.\n time.sleep(5)\n```\n", "Yes. You can also enable commit on all selects:\n\ndatabase.commit_select = True\n", "see https://github.com/coleifer/peewee/commit/6087199320a3ad8968add5d50f6c3a047767afdd\n\nI use 2.7.3 so every select not commit. upgrade to 2.8.0 to fix it. thanks.\n" ]
2016-04-12T06:39:42
2016-04-13T04:50:51
2016-04-12T14:42:46
NONE
null
``` python class MyRetryDB(RetryOperationalError, MySQLDatabase): pass database = MyRetryDB(DB_CFG['db'], **{'host': DB_CFG['host'], 'password': DB_CFG['passwd'], 'port': DB_CFG['port'], 'user': DB_CFG['user']}) class UnknownField(object): pass class BaseModel(Model): class Meta: database = database only_save_dirty = True class TVm(BaseModel): uuid = CharField(primary_key=True) cpu = IntegerField() mem = IntegerField() disk = IntegerField() createTime = DateTimeField() class Meta: db_table = 't_vm' ``` ``` python while True: uuid = '8d443fb7-3e30-4149-bb32-89ee5532eddc' a = TVm.select().where( TVm.uuid == uuid) for x in a: print x.createTime, x.mem time.sleep(5) ``` when I (or another process) update db data, this always print old data. can fetch realtime data, not cache in memory?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/910/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/910/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/909
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/909/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/909/comments
https://api.github.com/repos/coleifer/peewee/issues/909/events
https://github.com/coleifer/peewee/issues/909
147,321,856
MDU6SXNzdWUxNDczMjE4NTY=
909
create new record can't get the database default value.
{ "login": "Dongin", "id": 4242860, "node_id": "MDQ6VXNlcjQyNDI4NjA=", "avatar_url": "https://avatars.githubusercontent.com/u/4242860?v=4", "gravatar_id": "", "url": "https://api.github.com/users/Dongin", "html_url": "https://github.com/Dongin", "followers_url": "https://api.github.com/users/Dongin/followers", "following_url": "https://api.github.com/users/Dongin/following{/other_user}", "gists_url": "https://api.github.com/users/Dongin/gists{/gist_id}", "starred_url": "https://api.github.com/users/Dongin/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/Dongin/subscriptions", "organizations_url": "https://api.github.com/users/Dongin/orgs", "repos_url": "https://api.github.com/users/Dongin/repos", "events_url": "https://api.github.com/users/Dongin/events{/privacy}", "received_events_url": "https://api.github.com/users/Dongin/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Correct, because peewee is not magical, it will not magically retrieve a value that was created by the database server.\n\nYou look to be using MySQL, which AFAIK does not support INSERT ... RETURNING. So you will need to re-fetch the record or alternatively create the timestamp in Python and send it to the server.\n" ]
2016-04-11T05:42:49
2016-04-11T20:36:14
2016-04-11T20:36:14
NONE
null
``` class MyModel(Model): create_at = DateTimeField(constraints=[SQL('DEFAULT CURRENT_TIMESTAMP')], formats='%Y-%m-%d %H:%M:%S', verbose_name=‘Created time') other_fields = xxx inst = MyModel.create(other_fields=xxx) print inst.create_at is None ``` The output is **True**.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/909/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/909/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/908
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/908/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/908/comments
https://api.github.com/repos/coleifer/peewee/issues/908/events
https://github.com/coleifer/peewee/pull/908
146,988,919
MDExOlB1bGxSZXF1ZXN0NjU4MTk2MTU=
908
Update playhouse.rst
{ "login": "aaronwp", "id": 1002418, "node_id": "MDQ6VXNlcjEwMDI0MTg=", "avatar_url": "https://avatars.githubusercontent.com/u/1002418?v=4", "gravatar_id": "", "url": "https://api.github.com/users/aaronwp", "html_url": "https://github.com/aaronwp", "followers_url": "https://api.github.com/users/aaronwp/followers", "following_url": "https://api.github.com/users/aaronwp/following{/other_user}", "gists_url": "https://api.github.com/users/aaronwp/gists{/gist_id}", "starred_url": "https://api.github.com/users/aaronwp/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/aaronwp/subscriptions", "organizations_url": "https://api.github.com/users/aaronwp/orgs", "repos_url": "https://api.github.com/users/aaronwp/repos", "events_url": "https://api.github.com/users/aaronwp/events{/privacy}", "received_events_url": "https://api.github.com/users/aaronwp/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Hmm, but `tuple` does have `len`...\n\n``` python\nIn [1]: x = (1,2,3)\n\nIn [2]: len(x)\nOut[2]: 3\n```\n", "See my sample code below. For some reason I was thinking it was just a documentation issue, but perhaps it's a bug...? \n\n```\nmysql_db = PooledMySQLDatabase('dbname',\n host=os.environ['DB_HOST'],\n user=os.environ['DB_USER'],\n passwd=os.environ['DB_PASS'],\n max_connections=32,\n stale_timeout=300) # 5 minutes.\n\nmysql_read_db = PooledMySQLDatabase('dbname',\n host=os.environ['DB_READ_HOST'],\n user=os.environ['DB_USER'],\n passwd=os.environ['DB_PASS'],\n max_connections=32,\n stale_timeout=300) # 5 minutes.\n\ndef _db_close(exc):\n databases = [mysql_db,mysql_read_db]\n for database in databases:\n if not database.is_closed():\n database.close() \n\nclass BaseModel(ReadSlaveModel):\n class Meta:\n database = mysql_db\n read_slaves = [mysql_read_db] // <--- if (mysql_read_db) then i get error. \n\n```\n", "A tuple with only one item needs a trailing comma.\n\n(db,)\n" ]
2016-04-08T17:26:49
2016-04-09T21:19:43
2016-04-09T21:19:43
NONE
null
I think read_slaves needs to be a list not a tuple. I was getting `TypeError: object of type '....' has no len()` until I made this change.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/908/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/908/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/908", "html_url": "https://github.com/coleifer/peewee/pull/908", "diff_url": "https://github.com/coleifer/peewee/pull/908.diff", "patch_url": "https://github.com/coleifer/peewee/pull/908.patch", "merged_at": null }
https://api.github.com/repos/coleifer/peewee/issues/907
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/907/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/907/comments
https://api.github.com/repos/coleifer/peewee/issues/907/events
https://github.com/coleifer/peewee/issues/907
146,743,240
MDU6SXNzdWUxNDY3NDMyNDA=
907
pskel not included in install
{ "login": "charleschen", "id": 698190, "node_id": "MDQ6VXNlcjY5ODE5MA==", "avatar_url": "https://avatars.githubusercontent.com/u/698190?v=4", "gravatar_id": "", "url": "https://api.github.com/users/charleschen", "html_url": "https://github.com/charleschen", "followers_url": "https://api.github.com/users/charleschen/followers", "following_url": "https://api.github.com/users/charleschen/following{/other_user}", "gists_url": "https://api.github.com/users/charleschen/gists{/gist_id}", "starred_url": "https://api.github.com/users/charleschen/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/charleschen/subscriptions", "organizations_url": "https://api.github.com/users/charleschen/orgs", "repos_url": "https://api.github.com/users/charleschen/repos", "events_url": "https://api.github.com/users/charleschen/events{/privacy}", "received_events_url": "https://api.github.com/users/charleschen/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Not sure what happened...It doesn't look to have been in any release, so I guess I just spaced out. It will be included in the next release to pypi, which should be in the upcoming week or two.\n", "thanks!\n" ]
2016-04-07T21:10:12
2016-04-11T21:57:13
2016-04-11T20:49:48
NONE
null
installing latest version of peewee doesn't include pskel. was there a reason not to include it in the setup.py?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/907/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/907/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/906
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/906/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/906/comments
https://api.github.com/repos/coleifer/peewee/issues/906/events
https://github.com/coleifer/peewee/issues/906
146,343,120
MDU6SXNzdWUxNDYzNDMxMjA=
906
NoneType error when deleting an instance with multiple null foreign keys
{ "login": "nomorepanic", "id": 9201926, "node_id": "MDQ6VXNlcjkyMDE5MjY=", "avatar_url": "https://avatars.githubusercontent.com/u/9201926?v=4", "gravatar_id": "", "url": "https://api.github.com/users/nomorepanic", "html_url": "https://github.com/nomorepanic", "followers_url": "https://api.github.com/users/nomorepanic/followers", "following_url": "https://api.github.com/users/nomorepanic/following{/other_user}", "gists_url": "https://api.github.com/users/nomorepanic/gists{/gist_id}", "starred_url": "https://api.github.com/users/nomorepanic/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/nomorepanic/subscriptions", "organizations_url": "https://api.github.com/users/nomorepanic/orgs", "repos_url": "https://api.github.com/users/nomorepanic/repos", "events_url": "https://api.github.com/users/nomorepanic/events{/privacy}", "received_events_url": "https://api.github.com/users/nomorepanic/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Pushed a testcase... It passed locally on py2.7 with sqlite, so we'll see what's up.\n", "I found what's happening. My model has a nullable 'delete' field and that overwrites the delete method. \nThank you for prompt reply but it was my distraction :)\n\nYou could consider renaming the delete method to _delete, but I do not know whether this would make sense with peewee.\n" ]
2016-04-06T15:05:39
2016-04-07T16:00:44
2016-04-07T16:00:44
NONE
null
peewee raises a NoneType error when deleting an instance with multiple null foreign keys, e.g.: ``` Schools(Base): id = PrimaryKeyField(primary_key=True) name = CharField() Parent(Base): id = PrimaryKeyField(primary_key=True) name = CharField() Children(Base): id = PrimaryKeyField(primary_key=True) parent = ForeignKeyField(Parents, null=True) school = ForeignKeyField(Schools, null=True) age = IntegerField() ``` Then ``` somechild = Children(age=12) somechild.save() ... somechild.delete_instance() ``` Will result in this: ``` def delete_instance(self, recursive=False, delete_nullable=False): if recursive: dependencies = self.dependencies(delete_nullable) for query, fk in reversed(list(dependencies)): model = fk.model_class if fk.null and not delete_nullable: model.update(**{fk.name: None}).where(query).execute() else: model.delete().where(query).execute() >return self.delete().where(self._pk_expr()).execute() TypeError: 'NoneType' object is not callable ``` I was going to post this on Stackoverflow, but then I've seen that getattr(somechild, 'delete') returns None. I am using peewee 2.8.0 on python 3.4.3
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/906/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/906/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/905
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/905/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/905/comments
https://api.github.com/repos/coleifer/peewee/issues/905/events
https://github.com/coleifer/peewee/pull/905
145,890,284
MDExOlB1bGxSZXF1ZXN0NjUyNTI2NzA=
905
doc shows wrong default value for wrapped_count parameter
{ "login": "lixxu", "id": 264487, "node_id": "MDQ6VXNlcjI2NDQ4Nw==", "avatar_url": "https://avatars.githubusercontent.com/u/264487?v=4", "gravatar_id": "", "url": "https://api.github.com/users/lixxu", "html_url": "https://github.com/lixxu", "followers_url": "https://api.github.com/users/lixxu/followers", "following_url": "https://api.github.com/users/lixxu/following{/other_user}", "gists_url": "https://api.github.com/users/lixxu/gists{/gist_id}", "starred_url": "https://api.github.com/users/lixxu/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/lixxu/subscriptions", "organizations_url": "https://api.github.com/users/lixxu/orgs", "repos_url": "https://api.github.com/users/lixxu/repos", "events_url": "https://api.github.com/users/lixxu/events{/privacy}", "received_events_url": "https://api.github.com/users/lixxu/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Thank you for this!\n" ]
2016-04-05T05:22:27
2016-04-07T18:47:22
2016-04-07T18:47:17
CONTRIBUTOR
null
`wrapped_count` has default value `False` for `clear_limit`, but the doc shows `True`
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/905/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/905/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/905", "html_url": "https://github.com/coleifer/peewee/pull/905", "diff_url": "https://github.com/coleifer/peewee/pull/905.diff", "patch_url": "https://github.com/coleifer/peewee/pull/905.patch", "merged_at": "2016-04-07T18:47:17" }
https://api.github.com/repos/coleifer/peewee/issues/904
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/904/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/904/comments
https://api.github.com/repos/coleifer/peewee/issues/904/events
https://github.com/coleifer/peewee/pull/904
145,387,464
MDExOlB1bGxSZXF1ZXN0NjUwNDE1NjM=
904
Removed side effects while cleaning prefetch query
{ "login": "kammala", "id": 4599701, "node_id": "MDQ6VXNlcjQ1OTk3MDE=", "avatar_url": "https://avatars.githubusercontent.com/u/4599701?v=4", "gravatar_id": "", "url": "https://api.github.com/users/kammala", "html_url": "https://github.com/kammala", "followers_url": "https://api.github.com/users/kammala/followers", "following_url": "https://api.github.com/users/kammala/following{/other_user}", "gists_url": "https://api.github.com/users/kammala/gists{/gist_id}", "starred_url": "https://api.github.com/users/kammala/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/kammala/subscriptions", "organizations_url": "https://api.github.com/users/kammala/orgs", "repos_url": "https://api.github.com/users/kammala/repos", "events_url": "https://api.github.com/users/kammala/events{/privacy}", "received_events_url": "https://api.github.com/users/kammala/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Nice pull request, and nice catch. Thanks!\n" ]
2016-04-02T15:55:10
2016-04-03T02:40:00
2016-04-03T02:39:53
CONTRIBUTOR
null
There was a strange behaviour: then you do prefetch on complex query with some grouping, you will have some kind of exception or incorrect result. The reason of this is simple: `clean_prefetch_query` removes any information about grouping from query before placing it as subquery in prefetch queries, but it is done on original query instead of cloned one. This pr fixes this little bug(in a single code line ^_^).
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/904/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/904/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/904", "html_url": "https://github.com/coleifer/peewee/pull/904", "diff_url": "https://github.com/coleifer/peewee/pull/904.diff", "patch_url": "https://github.com/coleifer/peewee/pull/904.patch", "merged_at": "2016-04-03T02:39:53" }
https://api.github.com/repos/coleifer/peewee/issues/903
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/903/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/903/comments
https://api.github.com/repos/coleifer/peewee/issues/903/events
https://github.com/coleifer/peewee/issues/903
145,362,472
MDU6SXNzdWUxNDUzNjI0NzI=
903
Polymorphic relationships
{ "login": "smilledge", "id": 1536407, "node_id": "MDQ6VXNlcjE1MzY0MDc=", "avatar_url": "https://avatars.githubusercontent.com/u/1536407?v=4", "gravatar_id": "", "url": "https://api.github.com/users/smilledge", "html_url": "https://github.com/smilledge", "followers_url": "https://api.github.com/users/smilledge/followers", "following_url": "https://api.github.com/users/smilledge/following{/other_user}", "gists_url": "https://api.github.com/users/smilledge/gists{/gist_id}", "starred_url": "https://api.github.com/users/smilledge/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/smilledge/subscriptions", "organizations_url": "https://api.github.com/users/smilledge/orgs", "repos_url": "https://api.github.com/users/smilledge/repos", "events_url": "https://api.github.com/users/smilledge/events{/privacy}", "received_events_url": "https://api.github.com/users/smilledge/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "It's named Generic Foreign Keys. Check the Playhouse docs.\nOn Apr 2, 2016 2:07 PM, \"Sam Milledge\" [email protected] wrote:\n\n> Does peewee support polymorphic relationships?\n> \n> Would be awesome to have something similar to what is provided by Laravel\n> and Rails:\n> https://laravel.com/docs/5.1/eloquent-relationships#polymorphic-relations\n> \n> http://guides.rubyonrails.org/association_basics.html#polymorphic-associations\n> \n> —\n> You are receiving this because you are subscribed to this thread.\n> Reply to this email directly or view it on GitHub\n> https://github.com/coleifer/peewee/issues/903\n", "Didn't see that, thanks!\n", "Thanks @arikfr ! @smilledge feel free to reply if you have follow-up questions.\n", "I've made a simple generic foreign key implementation: https://gist.github.com/wonderbeyond/0e1f402b7595e0b4f9f653260fed029c#file-index-md" ]
2016-04-02T11:07:41
2018-03-19T09:27:44
2016-04-03T00:46:38
NONE
null
Does peewee support polymorphic relationships? Would be awesome to have something similar to what is provided by Laravel and Rails: https://laravel.com/docs/5.1/eloquent-relationships#polymorphic-relations http://guides.rubyonrails.org/association_basics.html#polymorphic-associations
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/903/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/903/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/902
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/902/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/902/comments
https://api.github.com/repos/coleifer/peewee/issues/902/events
https://github.com/coleifer/peewee/issues/902
144,563,715
MDU6SXNzdWUxNDQ1NjM3MTU=
902
TypeError: unhashable type: 'list' when using playhouse.dataset with Postgres
{ "login": "mivade", "id": 2805515, "node_id": "MDQ6VXNlcjI4MDU1MTU=", "avatar_url": "https://avatars.githubusercontent.com/u/2805515?v=4", "gravatar_id": "", "url": "https://api.github.com/users/mivade", "html_url": "https://github.com/mivade", "followers_url": "https://api.github.com/users/mivade/followers", "following_url": "https://api.github.com/users/mivade/following{/other_user}", "gists_url": "https://api.github.com/users/mivade/gists{/gist_id}", "starred_url": "https://api.github.com/users/mivade/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/mivade/subscriptions", "organizations_url": "https://api.github.com/users/mivade/orgs", "repos_url": "https://api.github.com/users/mivade/repos", "events_url": "https://api.github.com/users/mivade/events{/privacy}", "received_events_url": "https://api.github.com/users/mivade/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "I'm a bit at a loss. Can you tell me what `table.model._meta.primary_key` returns? As well as `table._meta.fields`. Thanks!\n", "Basically it looks like your table has a composite primary key, and when asked for `table.model._meta.primary_key.field_names`, it's returning a list of lists?\n", "Hm, that could be, although I don't quite understand why. I'll post the requested information tomorrow when I again have access to the real data as in the original issue.\n\nIn the meantime, I have an offline testing version which only uses a subset of the keys in the dict above. On my own computer running Postgres 9.4, there are no problems. So I am not sure if that is somehow related to using fewer keys/columns or if there is a version-specific bug.\n", "Is there an `id` column present in any of the data you're loading?\n", "I'm tempted to think this is just a data issue, but until you can get me the output (and even better the actual row data) when it crashes that'd be great.\n", "There is no explicit `id` column; only the columns given above in the form of keys exist. The table also does not exist prior to the `table.insert` call.\n", "I was able to resolve this problem by dropping the table which had been created prior to trying to write (but was empty) and letting peewee handle the table creation itself. However, before doing this, I checked the output of `table.model_class._meta.primary_key` and `table.model_class._meta.fields`. Using `sqlite:///:memory:`, on the first run, I get:\n\n```\nprimary key\n<peewee.PrimaryKeyField object at 0x7f64787617b8>\nfields\n{'id': <peewee.PrimaryKeyField object at 0x7f64787617b8>}\n```\n\nand after the initial insert:\n\n```\nprimary key\n<peewee.PrimaryKeyField object at 0x7fa7322206a0>\nfields\n{'beat1_lb_mon': <peewee.FloatField object at 0x7fa7322140b8>,\n 'beat1_lb_status': <peewee.IntegerField object at 0x7fa7322141d0>,\n 'beat1_signal': <peewee.FloatField object at 0x7fa732220fd0>,\n 'beat1_signalaux': <peewee.FloatField object at 0x7fa732220c18>,\n 'beat1_waveplate': <peewee.FloatField object at 0x7fa732220cf8>,\n 'beat2_lb_mon': <peewee.FloatField object at 0x7fa732214160>,\n 'beat2_lb_status': <peewee.IntegerField object at 0x7fa7322207b8>,\n 'beat2_signal': <peewee.FloatField object at 0x7fa732214748>,\n 'beat2_signalaux': <peewee.FloatField object at 0x7fa7322143c8>,\n 'counter0_freq': <peewee.FloatField object at 0x7fa732214198>,\n 'counter0_freqref': <peewee.FloatField object at 0x7fa732220ef0>,\n 'counter1_freq': <peewee.FloatField object at 0x7fa732220da0>,\n 'counter1_freqref': <peewee.FloatField object at 0x7fa7322147b8>,\n 'counter2_freq': <peewee.FloatField object at 0x7fa732220f28>,\n 'counter2_signal': <peewee.FloatField object at 0x7fa732220e48>,\n 'counter3_freq': <peewee.FloatField object at 0x7fa732214208>,\n 'counter3_signal': <peewee.FloatField object at 0x7fa732214048>,\n 'counter_channels': <peewee.IntegerField object at 0x7fa732220f60>,\n 'counter_gatetime': <peewee.FloatField object at 0x7fa732220eb8>,\n 'cw1_freq': <peewee.FloatField object at 0x7fa732220e10>,\n 'cw2_freq': <peewee.FloatField object at 0x7fa732220828>,\n 'id': <peewee.PrimaryKeyField object at 0x7fa7322206a0>,\n 'laser_mldet_ac': <peewee.FloatField object at 0x7fa732214400>,\n 'laser_mldet_dc': <peewee.FloatField object at 0x7fa732220b70>,\n 'lb1_mon': <peewee.FloatField object at 0x7fa732214390>,\n 'lb1_status': <peewee.IntegerField object at 0x7fa732220b00>,\n 'lb2_mon': <peewee.FloatField object at 0x7fa732214278>,\n 'lb2_status': <peewee.IntegerField object at 0x7fa732214358>,\n 'lb3_mon': <peewee.FloatField object at 0x7fa732220ac8>,\n 'lb3_status': <peewee.IntegerField object at 0x7fa732220dd8>,\n 'lb4_mon': <peewee.FloatField object at 0x7fa732214320>,\n 'lb4_status': <peewee.IntegerField object at 0x7fa732220ba8>,\n 'lb5_mon': <peewee.FloatField object at 0x7fa732214080>,\n 'lb5_status': <peewee.IntegerField object at 0x7fa732220c88>,\n 'lb6_mon': <peewee.FloatField object at 0x7fa732214438>,\n 'lb6_status': <peewee.IntegerField object at 0x7fa732220d68>,\n 'offset_freq': <peewee.FloatField object at 0x7fa732220cc0>,\n 'offset_freqref': <peewee.FloatField object at 0x7fa732220f98>,\n 'offset_signal': <peewee.FloatField object at 0x7fa732220b38>,\n 'offset_stage': <peewee.FloatField object at 0x7fa732220e80>,\n 'reprate_freq': <peewee.FloatField object at 0x7fa732220c50>,\n 'reprate_freqref': <peewee.FloatField object at 0x7fa732214128>,\n 'reprate_stage': <peewee.FloatField object at 0x7fa732220748>,\n 'syncro_adc_channel2': <peewee.FloatField object at 0x7fa732214240>,\n 'system_latency': <peewee.FloatField object at 0x7fa732214780>,\n 'system_locked': <peewee.IntegerField object at 0x7fa7322142b0>,\n 'system_locked_for': <peewee.FloatField object at 0x7fa7322140f0>,\n 'system_plo_ok': <peewee.IntegerField object at 0x7fa7322142e8>,\n 'timestamp': <peewee.FloatField object at 0x7fa732220d30>}\n```\n\nWith Postgres, prior to the insert (where it crashes):\n\n```\nprimary key\n<peewee.PrimaryKeyField object at 0x7f4afa8afb00>\nfields\n{'id': <peewee.PrimaryKeyField object at 0x7f4afa8afb00>}\n```\n\nIs there any other testing you can suggest to help figure out why this fails when the empty table exists?\n", "No idea, other than that the table perhaps is missing a primary key?\n" ]
2016-03-30T11:44:16
2016-03-31T21:03:26
2016-03-31T21:03:26
NONE
null
I'm attempting to use the `playhouse.dataset` to lazily write data to a Postgres database. The data looks like this: ``` python {'beat1_lb_mon': 10.0, 'beat1_lb_status': 0, 'beat1_signal': 0.750122, 'beat1_signalaux': 0.377197, 'beat1_waveplate': 32830.0, 'beat2_lb_mon': 10.0, 'beat2_lb_status': 0, 'beat2_signal': 0.388794, 'beat2_signalaux': 0.238648, 'counter0_freq': 20000375.73899996, 'counter0_freqref': 5000000.0, 'counter1_freq': 20000000.09199998, 'counter1_freqref': 20000000.0, 'counter2_freq': 59999999.972, 'counter2_signal': 0.7489009999999999, 'counter3_freq': 19548567.59900001, 'counter3_signal': 0.377808, 'counter_channels': 4, 'counter_gatetime': 1.0, 'cw1_freq': -80000000.06399998, 'cw2_freq': -39548567.69099999, 'laser_mldet_ac': 1168.0, 'laser_mldet_dc': 321.0, 'lb1_mon': 6.230468, 'lb1_status': 2, 'lb2_mon': 0.546822, 'lb2_status': 2, 'lb3_mon': 3.881493, 'lb3_status': 0, 'lb4_mon': 10.0, 'lb4_status': 0, 'lb5_mon': 0.593604, 'lb5_status': 0, 'lb6_mon': 0.96824, 'lb6_status': 0, 'offset_freq': 20000000.09199998, 'offset_freqref': 20000000.0, 'offset_signal': 0.8038329999999999, 'offset_stage': -14948.0, 'reprate_freq': 250000093.93475, 'reprate_freqref': 246250000.0, 'reprate_stage': -211159.0, 'syncro_adc_channel2': 0.002084, 'system_latency': 0.514801025390625, 'system_locked': True, 'system_locked_for': 13972.88214206696, 'system_plo_ok': True, 'timestamp': 1459337054.158} ``` Using a SQLite database for testing, everything seems to work properly including guessing of datatypes. However, when I switch to Postgres, I get the following traceback: ``` python Traceback (most recent call last): File "/home/iontrap/src/brush/env/bin/brush", line 9, in <module> load_entry_point('brush==1.0.0b2', 'console_scripts', 'brush')() File "/home/iontrap/src/brush/brush/cli.py", line 55, in main IOLoop.instance().run_sync(lambda: sweep.run()) File "/home/iontrap/src/brush/env/lib/python3.4/site-packages/tornado/ioloop.py", line 453, in run_sync return future_cell[0].result() File "/home/iontrap/src/brush/env/lib/python3.4/site-packages/tornado/concurrent.py", line 232, in result raise_exc_info(self._exc_info) File "<string>", line 3, in raise_exc_info File "/home/iontrap/src/brush/env/lib/python3.4/site-packages/tornado/gen.py", line 282, in wrapper yielded = next(result) File "/home/iontrap/src/brush/brush/sweep.py", line 97, in run self.write(data) File "/home/iontrap/src/brush/brush/sweep.py", line 67, in write id = table.insert(**data) File "/home/iontrap/src/brush/env/lib/python3.4/site-packages/playhouse/dataset.py", line 213, in insert return self.model_class.insert(**data).execute() File "/home/iontrap/src/brush/env/lib/python3.4/site-packages/peewee.py", line 3213, in execute cursor = self._execute() File "/home/iontrap/src/brush/env/lib/python3.4/site-packages/peewee.py", line 2627, in _execute sql, params = self.sql() File "/home/iontrap/src/brush/env/lib/python3.4/site-packages/peewee.py", line 3181, in sql return self.compiler().generate_insert(self) File "/home/iontrap/src/brush/env/lib/python3.4/site-packages/peewee.py", line 1885, in generate_insert meta.get_primary_key_fields(), File "/home/iontrap/src/brush/env/lib/python3.4/site-packages/peewee.py", line 4299, in get_primary_key_fields for field_name in self.primary_key.field_names] File "/home/iontrap/src/brush/env/lib/python3.4/site-packages/peewee.py", line 4299, in <listcomp> for field_name in self.primary_key.field_names] TypeError: unhashable type: 'list' ``` The `write` method is defined as: ``` python def write(self, data): table = self.db[options.sql_table] with self.db.transaction() as txn: id = table.insert(**data) if id == 1: for index in self.indices: try: table.create_index([index]) except OperationalError: # index already exists pass ``` This is using peewee 2.8.0 and a Postgres 9.3 server.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/902/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/902/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/901
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/901/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/901/comments
https://api.github.com/repos/coleifer/peewee/issues/901/events
https://github.com/coleifer/peewee/issues/901
144,405,924
MDU6SXNzdWUxNDQ0MDU5MjQ=
901
Migration to change CharField max_length
{ "login": "josefdlange", "id": 1062835, "node_id": "MDQ6VXNlcjEwNjI4MzU=", "avatar_url": "https://avatars.githubusercontent.com/u/1062835?v=4", "gravatar_id": "", "url": "https://api.github.com/users/josefdlange", "html_url": "https://github.com/josefdlange", "followers_url": "https://api.github.com/users/josefdlange/followers", "following_url": "https://api.github.com/users/josefdlange/following{/other_user}", "gists_url": "https://api.github.com/users/josefdlange/gists{/gist_id}", "starred_url": "https://api.github.com/users/josefdlange/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/josefdlange/subscriptions", "organizations_url": "https://api.github.com/users/josefdlange/orgs", "repos_url": "https://api.github.com/users/josefdlange/repos", "events_url": "https://api.github.com/users/josefdlange/events{/privacy}", "received_events_url": "https://api.github.com/users/josefdlange/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Indeed, for that you will need to probably consult the postgres manual for the correct SQL. Peewee handles most things, but this is one of the ones it doesn't.\n" ]
2016-03-29T22:19:01
2016-03-30T04:13:39
2016-03-30T04:13:39
CONTRIBUTOR
null
The title says the most of it. I'm using `arnold` for migrations on my PostgreSQL database, and I think I'd want to do something like: ``` def up(): config.DB.execute_sql("SOME arbitrary SQL to MODIFY column;") def down(): config.DB.execute_sql("OPPOSITE of ABOVE SQL code;") ``` Does that sound about right? I don't see any first-class features for changing the size of a Postgres VARCHAR.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/901/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/901/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/900
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/900/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/900/comments
https://api.github.com/repos/coleifer/peewee/issues/900/events
https://github.com/coleifer/peewee/issues/900
143,987,019
MDU6SXNzdWUxNDM5ODcwMTk=
900
Can I define a default ORDER BY for a relationship?
{ "login": "maaaks", "id": 3010238, "node_id": "MDQ6VXNlcjMwMTAyMzg=", "avatar_url": "https://avatars.githubusercontent.com/u/3010238?v=4", "gravatar_id": "", "url": "https://api.github.com/users/maaaks", "html_url": "https://github.com/maaaks", "followers_url": "https://api.github.com/users/maaaks/followers", "following_url": "https://api.github.com/users/maaaks/following{/other_user}", "gists_url": "https://api.github.com/users/maaaks/gists{/gist_id}", "starred_url": "https://api.github.com/users/maaaks/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/maaaks/subscriptions", "organizations_url": "https://api.github.com/users/maaaks/orgs", "repos_url": "https://api.github.com/users/maaaks/repos", "events_url": "https://api.github.com/users/maaaks/events{/privacy}", "received_events_url": "https://api.github.com/users/maaaks/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Your example foreign key definition doesn't make much sense...why would the foreign key be called \"child\" when it points at a Parent? I'm just going to assume this is a meaningless example...\n\nAt any rate, you can always just do:\n\n``` python\nclass Category(Model):\n parent = ForeignKeyField(\"self\", related_name=\"children_backref\")\n\n @property\n def children(self):\n return self.children_backref.order_by(Category.name)\n```\n" ]
2016-03-28T14:16:07
2016-03-29T18:56:51
2016-03-29T18:56:51
CONTRIBUTOR
null
I want something like this: ``` python child = ForeignKeyField(Parent, related_name="children", default_order_by="birthday") ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/900/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/900/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/899
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/899/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/899/comments
https://api.github.com/repos/coleifer/peewee/issues/899/events
https://github.com/coleifer/peewee/issues/899
143,778,546
MDU6SXNzdWUxNDM3Nzg1NDY=
899
Constraints not generated when using `DeferredRelation` with `ForeignKeyField`
{ "login": "frnhr", "id": 1173748, "node_id": "MDQ6VXNlcjExNzM3NDg=", "avatar_url": "https://avatars.githubusercontent.com/u/1173748?v=4", "gravatar_id": "", "url": "https://api.github.com/users/frnhr", "html_url": "https://github.com/frnhr", "followers_url": "https://api.github.com/users/frnhr/followers", "following_url": "https://api.github.com/users/frnhr/following{/other_user}", "gists_url": "https://api.github.com/users/frnhr/gists{/gist_id}", "starred_url": "https://api.github.com/users/frnhr/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/frnhr/subscriptions", "organizations_url": "https://api.github.com/users/frnhr/orgs", "repos_url": "https://api.github.com/users/frnhr/repos", "events_url": "https://api.github.com/users/frnhr/events{/privacy}", "received_events_url": "https://api.github.com/users/frnhr/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "http://docs.peewee-orm.com/en/latest/peewee/models.html#circular-foreign-key-dependencies\n\nIf you read through that section, you'll see towards the end that you need to explicitly create the foreign key constraint:\n\n> After initializing the deferred relation, the foreign key fields are now correctly set up. There is one more quirk to watch out for, though. When you call create_table we will again encounter the same issue. For this reason peewee will not automatically create a foreign key constraint for any deferred foreign keys.\n> \n> Here is how to create the tables:\n\n``` python\n# Foreign key constraint from User -> Tweet will NOT be created because the\n# Tweet table does not exist yet. `favorite_tweet` will just be a regular\n# integer field:\nUser.create_table()\n\n# Foreign key constraint from Tweet -> User will be created normally.\nTweet.create_table()\n\n# Now that both tables exist, we can create the foreign key from User -> Tweet:\n# NOTE: this will not work in SQLite!\ndb.create_foreign_key(User, User.favorite_tweet)\n```\n\n---\n\nIn your example, for one I think you copy/pasted wrong and the model below `User` should be \"PostThatsDeferred\", but more to the point: there's no reason for using a deferred relation. You can just write:\n\n``` python\nclass PostNotDeferred(BaseModel):\n title = CharField()\n\nclass PostThatsDeferred(BaseModel):\n title = CharField()\n\nclass User(BaseModel):\n username = CharField()\n post_not_deferred = ForeignKeyField(PostNotDeferred, null=True)\n post_thats_deferred = ForeignKeyField(PostThatsDeferred, null=True)\n```\n", "Thanks for your reply! It solved my problem.\n\nI wasn't reading carefully that particular section of the docs because I don't have a circular dependency in the db. Instead, one module is imported late and that's why I'm using `DeferredRelation`.\n" ]
2016-03-27T05:36:44
2016-03-29T21:23:18
2016-03-29T19:04:21
NONE
null
When using `DeferredRelation` with a `ForeignKeyField`, resulting MySQL table is missing a foreign key constraint. This constraint is present when regular model is passed to `ForeignKeyField`. Complete code to replicate the issue... foo.py: ``` """ Three models: PostNotDeferred ---< User >--- PostThatsDeferred """ from peewee import * database = MySQLDatabase('peeweetest', host='localhost', user='peeweetest', password='peeweetest') class BaseModel(Model): class Meta: database = database class PostNotDeferred(BaseModel): title = CharField() DeferredPost = DeferredRelation() class User(BaseModel): username = CharField() post_not_deferred = ForeignKeyField(PostNotDeferred, null=True) post_thats_deferred = ForeignKeyField(DeferredPost, null=True) class PostNotDeferred(BaseModel): title = CharField() DeferredPost.set_model(PostThatsDeferred) database.connect() database.create_tables([User, PostNotDeferred, PostThatsDeferred]) ``` Relevant part of mysqldump: ``` CREATE TABLE `user` ( `id` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(255) NOT NULL, `post_not_deferred_id` int(11) DEFAULT NULL, `post_thats_deferred_id` int(11) DEFAULT NULL, PRIMARY KEY (`id`), KEY `user_post_thats_deferred_id` (`post_thats_deferred_id`), KEY `user_post_not_deferred_id` (`post_not_deferred_id`), CONSTRAINT `user_ibfk_1` FOREIGN KEY (`post_not_deferred_id`) REFERENCES `postnotdeferred` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; ``` Only one `CONSTRAINT` is present, but two are expected. complete `mysqldump -u peeweetest -p peeweetest` output: ``` -- MySQL dump 10.13 Distrib 5.6.23, for osx10.10 (x86_64) -- -- Host: localhost Database: peeweetest -- ------------------------------------------------------ -- Server version 5.6.23 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -- -- Table structure for table `postnotdeferred` -- DROP TABLE IF EXISTS `postnotdeferred`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `postnotdeferred` ( `id` int(11) NOT NULL AUTO_INCREMENT, `title` varchar(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `postnotdeferred` -- LOCK TABLES `postnotdeferred` WRITE; /*!40000 ALTER TABLE `postnotdeferred` DISABLE KEYS */; /*!40000 ALTER TABLE `postnotdeferred` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `postthatsdeferred` -- DROP TABLE IF EXISTS `postthatsdeferred`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `postthatsdeferred` ( `id` int(11) NOT NULL AUTO_INCREMENT, `title` varchar(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `postthatsdeferred` -- LOCK TABLES `postthatsdeferred` WRITE; /*!40000 ALTER TABLE `postthatsdeferred` DISABLE KEYS */; /*!40000 ALTER TABLE `postthatsdeferred` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `user` -- DROP TABLE IF EXISTS `user`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `user` ( `id` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(255) NOT NULL, `post_not_deferred_id` int(11) DEFAULT NULL, `post_thats_deferred_id` int(11) DEFAULT NULL, PRIMARY KEY (`id`), KEY `user_post_thats_deferred_id` (`post_thats_deferred_id`), KEY `user_post_not_deferred_id` (`post_not_deferred_id`), CONSTRAINT `user_ibfk_1` FOREIGN KEY (`post_not_deferred_id`) REFERENCES `postnotdeferred` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `user` -- LOCK TABLES `user` WRITE; /*!40000 ALTER TABLE `user` DISABLE KEYS */; /*!40000 ALTER TABLE `user` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; -- Dump completed on 2016-03-27 7:17:29 ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/899/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/899/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/898
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/898/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/898/comments
https://api.github.com/repos/coleifer/peewee/issues/898/events
https://github.com/coleifer/peewee/issues/898
143,776,432
MDU6SXNzdWUxNDM3NzY0MzI=
898
Is it possible to do a coalesce with peewee?
{ "login": "KrisSiegel", "id": 1885826, "node_id": "MDQ6VXNlcjE4ODU4MjY=", "avatar_url": "https://avatars.githubusercontent.com/u/1885826?v=4", "gravatar_id": "", "url": "https://api.github.com/users/KrisSiegel", "html_url": "https://github.com/KrisSiegel", "followers_url": "https://api.github.com/users/KrisSiegel/followers", "following_url": "https://api.github.com/users/KrisSiegel/following{/other_user}", "gists_url": "https://api.github.com/users/KrisSiegel/gists{/gist_id}", "starred_url": "https://api.github.com/users/KrisSiegel/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/KrisSiegel/subscriptions", "organizations_url": "https://api.github.com/users/KrisSiegel/orgs", "repos_url": "https://api.github.com/users/KrisSiegel/repos", "events_url": "https://api.github.com/users/KrisSiegel/events{/privacy}", "received_events_url": "https://api.github.com/users/KrisSiegel/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Yep, it's possible.\n\ne.g.:\n\n``` python\nSomeModel.select(fn.COALESCE(SomeModel.field_a, SomeModel.field_b).alias('the_value))\n```\n", "Thanks, didn't see that in the documentation anywhere.\n", "It's described here:\n\nhttp://docs.peewee-orm.com/en/latest/peewee/querying.html#sql-functions-subqueries-and-raw-expressions\n", "That doesn't actually mention coalesce only that you can _\"use arbitrary SQL functions\"_ but how do I know which functions are supported through PeeWee? Or do they _only_ map directly back to the database I have setup? For instance not every DB has ISNULL.\n\nIf the documentation was a little more clear either way it would be helpful. I think it would be nice to list all functions available across all databases versus what's available for individual ones. Or at least the verified working through PeeWee functions.\n", "Literally the third sentence:\n\n> To use arbitrary SQL functions, use the special fn() object to construct queries:\n\nYou can call literally any function, whether it exists or not. It's just syntactic sugar, read the code to get an understanding of how it works. You can nest calls to functions, you can do whatever.\n\n> I think it would be nice to list all functions available across all databases versus what's available for individual ones.\n\nThat's stupid. Why would I do that? Read your database documentation, no sense in duplicating it.\n", "> Literally the third sentence:\n\nYou and I both made reference to that passage and it doesn't address my specific statement so I'm not sure what you gain by reiterating a point we've both talked about. Regardless...\n\n> That's stupid. Why would I do that?\n\nSo my comment already addressed the why. But if you think the suggestion is stupid I can't tell if you just ignored my 'whys' or you want other 'whys' without addressing my original ones. Regardless this doesn't sound like a productive conversation so no need to continue it.\n", "The word _arbitrary_ means _any_ in the sentence I referenced. Meaning there's no need to duplicate other database vendors documentation since Peewee can call literally any function. The `fn` object creates a `Function` instance that the query compiler turns into a function call in SQL. Peewee doesn't have to know any more than that.\n", "@KrisSiegel \n\n> I think it would be nice to list all functions available across all databases versus what's available for individual ones.\n\nWhat about [personal functions](http://www.postgresql.org/docs/9.5/static/sql-createfunction.html)? ;-)\n", "FWIW I got here by googling \"peewee coalesce\". I started developing using Peewee without reading the docs end-to-end, so this issue helped me.", "@skatenerd, interestingly, we're just exactly a month apart in using this issue to figure out how to use a `COALESCE` in Peewee." ]
2016-03-27T04:42:03
2020-10-10T17:26:22
2016-03-29T19:08:58
NONE
null
I have 3 fields that I want to return as one field (2 of the 3 will _always_ be NULL so I only want the one with a value) but I haven't been able to find any documentation that shows a way to handle this in PeeWee. Am I missing something?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/898/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/898/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/897
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/897/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/897/comments
https://api.github.com/repos/coleifer/peewee/issues/897/events
https://github.com/coleifer/peewee/issues/897
143,462,314
MDU6SXNzdWUxNDM0NjIzMTQ=
897
Is it possible to load multiple JOINed models using a RawQuery?
{ "login": "maaaks", "id": 3010238, "node_id": "MDQ6VXNlcjMwMTAyMzg=", "avatar_url": "https://avatars.githubusercontent.com/u/3010238?v=4", "gravatar_id": "", "url": "https://api.github.com/users/maaaks", "html_url": "https://github.com/maaaks", "followers_url": "https://api.github.com/users/maaaks/followers", "following_url": "https://api.github.com/users/maaaks/following{/other_user}", "gists_url": "https://api.github.com/users/maaaks/gists{/gist_id}", "starred_url": "https://api.github.com/users/maaaks/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/maaaks/subscriptions", "organizations_url": "https://api.github.com/users/maaaks/orgs", "repos_url": "https://api.github.com/users/maaaks/repos", "events_url": "https://api.github.com/users/maaaks/events{/privacy}", "received_events_url": "https://api.github.com/users/maaaks/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "As far as I understand, [`generate_column_map()`](https://github.com/coleifer/peewee/blob/65dbfc5b3b406278df15d55bd48dbfc4ab6f7d6f/peewee.py#L2205) generates a list containing every field in every model mentioned in `select()`, in the same order as they are defined in classes. Can I consider this a defined behavior? If yes, does it mean that I can just inherit from `RawQuery` and somehow force it to use the [`AggregateQueryResultWrapper`](https://github.com/coleifer/peewee/blob/65dbfc5b3b406278df15d55bd48dbfc4ab6f7d6f/peewee.py#L2316) in order to use results of my own query, and that I _do not need_ to use some specific table aliases?\n", "No, it doesn't work because `AggregateQueryResultWrapper` also needs `_selects` and `_joins` fields which exist only in `SelectQuery` (and `RawQuery` is not a `SelectQuery`). :-(\n", "By the way, is there any way to add a custom field to a model in `RawQuery`? E.g. field named `level`, for walking through a recursive result.\n", "`RawQuery` does not support any fancy related-instance juju. It will simply patch all attributes returned by the cursor onto the model instance (or the dictionary or tuple if you're using .dicts() or .tuples()). There is not enough information available to peewee to generate the graph of joined models reliably.\n\nYou can, of course, write a wrapper that does the transformations you want.\n\nAlternatively you can use the regular SelectQuery type of query, which supports traversing the model graph to reconstruct joined instances.\n\nYes, you can add whatever attributes you want with both RawQuery and SelectQuery.\n\nFor example:\n\n``` python\nclass User(Model):\n username = CharField()\n\nusers = User.select(User.username, fn.LOWER(User.username).alias('all_lower_username'))\nfor user in users:\n print user.all_lower_username\n\nusers = User.raw('SELECT username, LOWER(username) AS all_lower_username FROM user')\n# same as above.\n```\n", "Please respond if the above did not address your question and I'll re-open to discuss further.\n", "> ``` sql\n> python = User.raw('SELECT username, LOWER(username) AS all_lower_username FROM user')\n> ```\n\nI don't understand where will the `all_lower_username` go here? Will it become available as `user.all_lower_username` or something?\n", "Yes, user.all_lower_username\n" ]
2016-03-25T09:20:06
2016-04-23T17:20:13
2016-04-23T02:40:18
CONTRIBUTOR
null
If yes, how should I write the query, which aliases to use for rows? For example, I want to load a `Site` object with joined `Page` objects which should be loaded using a custom recursive query.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/897/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/897/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/896
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/896/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/896/comments
https://api.github.com/repos/coleifer/peewee/issues/896/events
https://github.com/coleifer/peewee/issues/896
142,968,771
MDU6SXNzdWUxNDI5Njg3NzE=
896
Commit after select
{ "login": "asztalosdani", "id": 9664767, "node_id": "MDQ6VXNlcjk2NjQ3Njc=", "avatar_url": "https://avatars.githubusercontent.com/u/9664767?v=4", "gravatar_id": "", "url": "https://api.github.com/users/asztalosdani", "html_url": "https://github.com/asztalosdani", "followers_url": "https://api.github.com/users/asztalosdani/followers", "following_url": "https://api.github.com/users/asztalosdani/following{/other_user}", "gists_url": "https://api.github.com/users/asztalosdani/gists{/gist_id}", "starred_url": "https://api.github.com/users/asztalosdani/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/asztalosdani/subscriptions", "organizations_url": "https://api.github.com/users/asztalosdani/orgs", "repos_url": "https://api.github.com/users/asztalosdani/repos", "events_url": "https://api.github.com/users/asztalosdani/events{/privacy}", "received_events_url": "https://api.github.com/users/asztalosdani/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Actually, `PostgresqlDatabase` does call commit after every select query. How are you declaring / instantiating your database? What type of app is this?\n", "It's a QT app, working in Maya, connecting to DB to select the project, then the asset you will work on.\nPostgresqlDatabase was instanciated with autocommit=False. I changed it to True, now it seems to work.\nBut why is the select run in transaction?\n", "> was instanciated with autocommit=False\n\nThis.\n\nUnless you really understand Peewee's transaction management ID suggest using autocommit=True and using the provided `atomic` decorator/context manager when you want explicit transactions.\n", "But why is the select run in transaction?\r\n\r\n@coleifer can you answer this question?", "The `SELECT` is \"run in a transaction\" because queries are always run in transactions, it's just that in autocommit mode those transactions are only 1 query long. In \"autocommit\" there's a commit() after each query to avoid leaving open, idle transactions. See #806 and #727 for a little more background.\r\n\r\nI understand your question, but also bear in mind that when you're not within the scope of an explicit `atomic()` or `transaction()` block, then essentially each individual query you execute is going to be in its own transaction." ]
2016-03-23T14:07:45
2017-03-06T15:40:05
2016-03-23T16:24:20
NONE
null
Hi! I am using peewee with PostgreSQL. I have tons of connections, which are 'idle in transaction', even if they use only select statements. If I call commit(), it becomes 'idle'. Why is there a transaction for the selects? Do I need to explicitly call commit? Example: ``` plist = Person.select() for person in plist: print(person.name, person.birthday) # db.commit() raw_input("Press Enter to continue...") ``` This leaves the connection 'idle in transaction', when using commit(), it's ok. What is the correct way to handle this? Thanks.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/896/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/896/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/895
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/895/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/895/comments
https://api.github.com/repos/coleifer/peewee/issues/895/events
https://github.com/coleifer/peewee/issues/895
142,964,920
MDU6SXNzdWUxNDI5NjQ5MjA=
895
How do I update a foreign key directly?
{ "login": "maaaks", "id": 3010238, "node_id": "MDQ6VXNlcjMwMTAyMzg=", "avatar_url": "https://avatars.githubusercontent.com/u/3010238?v=4", "gravatar_id": "", "url": "https://api.github.com/users/maaaks", "html_url": "https://github.com/maaaks", "followers_url": "https://api.github.com/users/maaaks/followers", "following_url": "https://api.github.com/users/maaaks/following{/other_user}", "gists_url": "https://api.github.com/users/maaaks/gists{/gist_id}", "starred_url": "https://api.github.com/users/maaaks/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/maaaks/subscriptions", "organizations_url": "https://api.github.com/users/maaaks/orgs", "repos_url": "https://api.github.com/users/maaaks/repos", "events_url": "https://api.github.com/users/maaaks/events{/privacy}", "received_events_url": "https://api.github.com/users/maaaks/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Fixed, thanks for reporting.\n", "For what it's worth you can always set the actual foreign key field to an integer ID:\n\n``` python\nmodel.relatedmodel = 1\n```\n", "This is great. It always seemed odd to me to assign an integer to an attribute that really should be an object.\n\nDoes this change also allow creating and querying via the same identifiers? e.g.\n\n`Foo(relatedmodel_id=1)`\n\nor\n\n`Foo.select().where(Foo.relatedmodel_id == 1)`\n", "At the moment creation is supported, but for querying you will still need to use the foreign key field itself. And honestly, I don't think I'll change it.\n", "Ok thanks.\n\nSomewhat related: Is there any reason accessing a non-existent field doesn't issue an error/warning. I've spent a decent amount of time tracking down issues that end up being due to using an incorrect field name, e.g.:\n\n``` python\n# Incorrect\nUser.select().where(User.city_id == 1) # This looks valid to me, but will result in the wrong query (with no error/warning)\nUser.create(city_id=1) # This one works as of 2.8.1, but previously I'd end up scratching my head over why the city_id field wasn't getting set\n```\n", "That should raise an exception, I will reopen.\n", "Cool. Thanks! And just to clarify, the second case can still occur with other values, e.g.\n\n``` python\n# These \"work\", but I would expect an exception\nuser = User.create(non_existent_field=44)\nuser = User(non_existent_field=235)\n```\n", "I actually decided to go ahead and support querying on the `xxx_id` field.\n" ]
2016-03-23T13:52:48
2016-05-04T20:28:16
2016-05-04T20:28:16
CONTRIBUTOR
null
This doesn't seem to work: ``` python model.relatedmodel_id = 1 ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/895/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/895/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/894
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/894/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/894/comments
https://api.github.com/repos/coleifer/peewee/issues/894/events
https://github.com/coleifer/peewee/issues/894
142,748,363
MDU6SXNzdWUxNDI3NDgzNjM=
894
Blob fields of variable (possibly huge) size?
{ "login": "gitttt", "id": 9463528, "node_id": "MDQ6VXNlcjk0NjM1Mjg=", "avatar_url": "https://avatars.githubusercontent.com/u/9463528?v=4", "gravatar_id": "", "url": "https://api.github.com/users/gitttt", "html_url": "https://github.com/gitttt", "followers_url": "https://api.github.com/users/gitttt/followers", "following_url": "https://api.github.com/users/gitttt/following{/other_user}", "gists_url": "https://api.github.com/users/gitttt/gists{/gist_id}", "starred_url": "https://api.github.com/users/gitttt/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/gitttt/subscriptions", "organizations_url": "https://api.github.com/users/gitttt/orgs", "repos_url": "https://api.github.com/users/gitttt/repos", "events_url": "https://api.github.com/users/gitttt/events{/privacy}", "received_events_url": "https://api.github.com/users/gitttt/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Wow, I'm not sure how to advise you, I'd suggest consulting the MySQL documentation and if that doesn't help, seeing about reaching out on whatever support channels they have...or StackOverflow?\n\nIf you want to do a LONGBLOB field in peewee, you'll need to add a custom field type for it as blob fields correspond to plain old \"BLOB\" columns in MySQL. Your code would look like:\n\n``` python\nclass LongBlobField(BlobField):\n db_field = 'longblob'\n\ndb = MySQLDatabase('my_db', fields={'longblob': 'LONGBLOB'})\n```\n\nYou might also consider storing the blobs externally on the filesystem -- some databases aren't optimized for storing massive values in every row.\n\nRegarding postgres, again you should consult their docs.\n", "Thanks for the code snipped. Seems to work nicely for me.\n" ]
2016-03-22T19:07:50
2016-03-25T15:49:30
2016-03-23T14:55:56
NONE
null
Is it possible to create fields of variable (possibly huge) size? I am currently using `memory_content = BlobField(null=True)`. This seems not to be the right choice as I get `/opt/Python2.7-32bit/lib/python2.7/site-packages/pymysql/cursors.py:158: Warning: Data truncated for column 'memory_content' at row 1` I am using mysql, i.e. the `BlobField()`is translated to a mysql blob. The mysql docu says: > A BLOB is a binary large object that can hold a variable amount of data. The four BLOB types are TINYBLOB, BLOB, MEDIUMBLOB, and LONGBLOB. These differ only in the maximum length of the values they can hold. Do I have to create a custom field as discussed [here](http://docs.peewee-orm.com/en/latest/peewee/models.html#custom-fields)? Or can I use another already existing field type (maybe CharField?) Would it be any different with postgresql ? What is the peewee best practice here?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/894/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/894/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/893
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/893/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/893/comments
https://api.github.com/repos/coleifer/peewee/issues/893/events
https://github.com/coleifer/peewee/pull/893
142,600,293
MDExOlB1bGxSZXF1ZXN0NjM2OTQ3NzE=
893
Fix logic error
{ "login": "lneoe", "id": 2282449, "node_id": "MDQ6VXNlcjIyODI0NDk=", "avatar_url": "https://avatars.githubusercontent.com/u/2282449?v=4", "gravatar_id": "", "url": "https://api.github.com/users/lneoe", "html_url": "https://github.com/lneoe", "followers_url": "https://api.github.com/users/lneoe/followers", "following_url": "https://api.github.com/users/lneoe/following{/other_user}", "gists_url": "https://api.github.com/users/lneoe/gists{/gist_id}", "starred_url": "https://api.github.com/users/lneoe/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/lneoe/subscriptions", "organizations_url": "https://api.github.com/users/lneoe/orgs", "repos_url": "https://api.github.com/users/lneoe/repos", "events_url": "https://api.github.com/users/lneoe/events{/privacy}", "received_events_url": "https://api.github.com/users/lneoe/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Thanks, I've committed equivalent patch with a testcase. I appreciate this fix!!\n" ]
2016-03-22T10:04:06
2016-03-23T14:52:01
2016-03-23T14:51:42
NONE
null
## Fixed - fix logic error in `playhouse.shortcuts.model_to_dict` if `backrefs = True`, only `descriptor` and `foreign_key` fields both not in the `only` will excute `continue` ``` class User(Model): name = CharField() class Tweet(Model): use = ForeignKeyField(User, related_name='tweets') user = User(name='tim') tweet = Tweet(user=user, content='my first tweets') ``` I define two model `User` and `Tweet`, and when I use `model_to_dict`, the output is ``` d = model_to_dict(user, only=[User.name, User.tweets, Tweet.content], backrefs=True) print(d) >>> {'name': 'tim'} ``` but the expect results should be ``` >>> {'name': 'tim', 'tweets': {'content': 'my first tweets'}} ``` This PR fixed this issue
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/893/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/893/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/893", "html_url": "https://github.com/coleifer/peewee/pull/893", "diff_url": "https://github.com/coleifer/peewee/pull/893.diff", "patch_url": "https://github.com/coleifer/peewee/pull/893.patch", "merged_at": null }
https://api.github.com/repos/coleifer/peewee/issues/892
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/892/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/892/comments
https://api.github.com/repos/coleifer/peewee/issues/892/events
https://github.com/coleifer/peewee/issues/892
142,380,397
MDU6SXNzdWUxNDIzODAzOTc=
892
Create makes table, but no columns
{ "login": "Neotric", "id": 17950579, "node_id": "MDQ6VXNlcjE3OTUwNTc5", "avatar_url": "https://avatars.githubusercontent.com/u/17950579?v=4", "gravatar_id": "", "url": "https://api.github.com/users/Neotric", "html_url": "https://github.com/Neotric", "followers_url": "https://api.github.com/users/Neotric/followers", "following_url": "https://api.github.com/users/Neotric/following{/other_user}", "gists_url": "https://api.github.com/users/Neotric/gists{/gist_id}", "starred_url": "https://api.github.com/users/Neotric/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/Neotric/subscriptions", "organizations_url": "https://api.github.com/users/Neotric/orgs", "repos_url": "https://api.github.com/users/Neotric/repos", "events_url": "https://api.github.com/users/Neotric/events{/privacy}", "received_events_url": "https://api.github.com/users/Neotric/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "I am positive there is a bug in your code somewhere. I'd suggest posting on stackoverflow and INCLUDE YOUR MODEL DEFINITION and code you're using to create the table. That'll help get the problem fixed the fastest.\n\nThis page is for tracking bugs with peewee and creating tables is covered extensively by tests.\n" ]
2016-03-21T15:18:27
2016-03-21T15:25:46
2016-03-21T15:25:46
NONE
null
Hello, Tried my first steps with peewee, looks good, but.... I did a create_table(mytable), the table was created, but none of the defined columns in the class mytable. I want three columns, all CharField(). I only get an column "id" INTEGER NOT NULL PRIMARY KEY. On data insertion rows are created with one column ("id"), but no other data. Who can help me ? What is going wrong ?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/892/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/892/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/891
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/891/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/891/comments
https://api.github.com/repos/coleifer/peewee/issues/891/events
https://github.com/coleifer/peewee/issues/891
142,194,454
MDU6SXNzdWUxNDIxOTQ0NTQ=
891
What is the reason to use keyword argument in positional style?
{ "login": "kiddten", "id": 9250239, "node_id": "MDQ6VXNlcjkyNTAyMzk=", "avatar_url": "https://avatars.githubusercontent.com/u/9250239?v=4", "gravatar_id": "", "url": "https://api.github.com/users/kiddten", "html_url": "https://github.com/kiddten", "followers_url": "https://api.github.com/users/kiddten/followers", "following_url": "https://api.github.com/users/kiddten/following{/other_user}", "gists_url": "https://api.github.com/users/kiddten/gists{/gist_id}", "starred_url": "https://api.github.com/users/kiddten/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/kiddten/subscriptions", "organizations_url": "https://api.github.com/users/kiddten/orgs", "repos_url": "https://api.github.com/users/kiddten/repos", "events_url": "https://api.github.com/users/kiddten/events{/privacy}", "received_events_url": "https://api.github.com/users/kiddten/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "No, it's not better. It's just that you think it's better.\n" ]
2016-03-20T19:17:05
2016-03-21T14:26:25
2016-03-21T14:26:25
NONE
null
https://peewee.readthedocs.org/en/2.0.2/peewee/cookbook.html#using-with-postgresql ``` python psql_db = PostgresqlDatabase('my_database', user='code') ``` Isn't ``` python psql_db = PostgresqlDatabase(database='my_database', user='code') ``` better? I understand that that is matter of taste. But it's kind of official docs.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/891/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/891/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/890
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/890/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/890/comments
https://api.github.com/repos/coleifer/peewee/issues/890/events
https://github.com/coleifer/peewee/issues/890
142,073,140
MDU6SXNzdWUxNDIwNzMxNDA=
890
VersionedModel
{ "login": "kramer65", "id": 596581, "node_id": "MDQ6VXNlcjU5NjU4MQ==", "avatar_url": "https://avatars.githubusercontent.com/u/596581?v=4", "gravatar_id": "", "url": "https://api.github.com/users/kramer65", "html_url": "https://github.com/kramer65", "followers_url": "https://api.github.com/users/kramer65/followers", "following_url": "https://api.github.com/users/kramer65/following{/other_user}", "gists_url": "https://api.github.com/users/kramer65/gists{/gist_id}", "starred_url": "https://api.github.com/users/kramer65/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/kramer65/subscriptions", "organizations_url": "https://api.github.com/users/kramer65/orgs", "repos_url": "https://api.github.com/users/kramer65/repos", "events_url": "https://api.github.com/users/kramer65/events{/privacy}", "received_events_url": "https://api.github.com/users/kramer65/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "This is neat, but I think it would be more appropriate as a separate library. There are quite a few opinions in this code, and I prefer to keep the playhouse stuff a bit more generic than this module.\n\nBe happy to add a link in the docs if you end up releasing it as a library.\n", "@coleifer \n\nThanks for your response. releasing it as a separate lib would be fine as well. \n\nRegarding the \"opinions\" in this code, I would really appreciate _your_ opinions and remarks for improvement on this code. Are there any areas that can be changed which could make the usage of this code more intuitive/pythonic for programmers? \n\nAll tips are welcome!\n" ]
2016-03-19T15:40:31
2016-03-20T08:29:59
2016-03-19T21:59:11
NONE
null
Hi @coleifer I needed a way to keep the full history of all records so that after an update I know what changed or after a delete I know what was deleted. So I had a brilliant programmer (not me) create some code, which I [just committed here](https://github.com/kramer65/peewee/blob/feature/versioned/playhouse/versioned.py) (with [tests here](https://github.com/kramer65/peewee/blob/feature/versioned/playhouse/tests/test_versioned.py)) Here is an example of how this can be used: ``` from peewee import CharField, DateField, BooleanField, SqliteDatabase from playhouse.versioned import VersionedModel # Setup a database sqlite_database = SqliteDatabase(':memory:') # Base class inherits ``VersionedModel`` instead of peewee.Model class People(VersionedModel): class Meta: database = sqlite_database # The actual table we are interested in. class Person(People): name = CharField() is_relative = BooleanField() Person.create_table() # Let's create a record and change it around a couple times person = Person() person.name = 'MIKE' person.is_relative=False person.save() # first save person.name = 'mike' person.save() # second save person.is_relative = True person.save() # third save # We now stored 1 record in the `person` table, and 3 records in the `personversion` table. # We can loop through all the versions of this record like this: for version in person._versions.order_by(person._VersionModel._id): print version._original_record_id, version._version_id, version.valid_from, version.valid_until, version.name, version.is_relative # This prints out #1 1 2016-03-19 16:34:34.453254 2016-03-19 16:34:34.458547 MIKE False #1 2 2016-03-19 16:34:34.459667 2016-03-19 16:34:34.460844 mike False #1 3 2016-03-19 16:34:34.461830 None mike True # We can also revert back to a previous version, which simply adds a new line to the `personversion` table. # So reverting back to version 2, sets the new version to 4 print person.version_id, person.name, person.is_relative # 3 mike True person.revert(2) print person.version_id, person.name, person.is_relative # 4 mike False # Let's see all the versions of this record again: for version in person._versions.order_by(person._VersionModel._id): print version._original_record_id, version._version_id, version.valid_from, version.valid_until, version.name, version.is_relative # This prints out #1 1 2016-03-19 16:34:34.453254 2016-03-19 16:34:34.458547 MIKE False #1 2 2016-03-19 16:34:34.459667 2016-03-19 16:34:34.460844 mike False #1 3 2016-03-19 16:34:34.461830 2016-03-19 16:34:34.465116 mike True #1 4 2016-03-19 16:34:34.466063 None mike False ``` The following attributes can not be used in classes that inherit from VersionedModel - valid_from - valid_until - deleted - _original_record_id - _original_record - _id If you bypass the normal save(), create(), and delete_instance() methods, signals will not be sent, and the model history will not be saved. Some dangerous commands noticed from testing include: (there may be more) - .insert() - .insert_many() - .delete() # class level Any comments on this code are very welcome. Would be open to merging this into master?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/890/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/890/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/889
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/889/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/889/comments
https://api.github.com/repos/coleifer/peewee/issues/889/events
https://github.com/coleifer/peewee/issues/889
141,833,950
MDU6SXNzdWUxNDE4MzM5NTA=
889
LookupError: unknown encoding: utf8mb4
{ "login": "fraba", "id": 4167193, "node_id": "MDQ6VXNlcjQxNjcxOTM=", "avatar_url": "https://avatars.githubusercontent.com/u/4167193?v=4", "gravatar_id": "", "url": "https://api.github.com/users/fraba", "html_url": "https://github.com/fraba", "followers_url": "https://api.github.com/users/fraba/followers", "following_url": "https://api.github.com/users/fraba/following{/other_user}", "gists_url": "https://api.github.com/users/fraba/gists{/gist_id}", "starred_url": "https://api.github.com/users/fraba/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/fraba/subscriptions", "organizations_url": "https://api.github.com/users/fraba/orgs", "repos_url": "https://api.github.com/users/fraba/repos", "events_url": "https://api.github.com/users/fraba/events{/privacy}", "received_events_url": "https://api.github.com/users/fraba/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "This error is coming from the MySQL driver so I suspect that peewee isn't the issue... But.\n\nDoes peewee need to run any special queries before the create table query?\n" ]
2016-03-18T10:53:16
2016-03-21T15:13:45
2016-03-21T15:13:45
NONE
null
I'm not sure whether the problem is linked to my specific settings, but it seems I can't do `table_exists` on connection with a mysql database using `charset = utf8mb4`. I previously altered my database with ``` SET NAMES utf8mb4; ALTER DATABASE my_database CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci; ``` but ``` File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 4548, in table_exists return cls._meta.db_table in cls._meta.database.get_tables(**kwargs) File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 3879, in get_tables return [row for row, in self.execute_sql('SHOW TABLES')] File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 3454, in execute_sql cursor.execute(sql, params or ()) File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 174, in execute self.errorhandler(self, exc, value) File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler raise errorclass, errorvalue LookupError: unknown encoding: utf8mb4 ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/889/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/889/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/888
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/888/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/888/comments
https://api.github.com/repos/coleifer/peewee/issues/888/events
https://github.com/coleifer/peewee/issues/888
141,289,552
MDU6SXNzdWUxNDEyODk1NTI=
888
Can't do eager loading
{ "login": "maaaks", "id": 3010238, "node_id": "MDQ6VXNlcjMwMTAyMzg=", "avatar_url": "https://avatars.githubusercontent.com/u/3010238?v=4", "gravatar_id": "", "url": "https://api.github.com/users/maaaks", "html_url": "https://github.com/maaaks", "followers_url": "https://api.github.com/users/maaaks/followers", "following_url": "https://api.github.com/users/maaaks/following{/other_user}", "gists_url": "https://api.github.com/users/maaaks/gists{/gist_id}", "starred_url": "https://api.github.com/users/maaaks/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/maaaks/subscriptions", "organizations_url": "https://api.github.com/users/maaaks/orgs", "repos_url": "https://api.github.com/users/maaaks/repos", "events_url": "https://api.github.com/users/maaaks/events{/privacy}", "received_events_url": "https://api.github.com/users/maaaks/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "You have a couple options, as described in the docs:\n\nhttp://docs.peewee-orm.com/en/latest/peewee/querying.html#avoiding-n-1-queries\n\nUse prefetch (my recommendation). This will run 4 queries (one for each table). Duplicates are not fetched, so there is no de-duping required.\n\n``` python\nhosted = HostedSite.select().where(HostedSite.domain == domain)\npages = HostedSitePage.select().order_by(HostedSitePage.order_num)\nsites = prefetch(hosted, pages, HostedSitePageToType, ObjectType)\nsite = sites.first()\n\nprint site.domain\n# The backref here is whatever the default backref is + '_prefetch':\nfor page in site.pages_prefetch:\n print ' - ' + page.title\n for page_to_type in page.hostedsitepagetotype_set_prefetch:\n print ' - ' + page_to_type.object_type.table_name\n```\n\nUse `aggregate_rows()`. This requires de-duping in Python. Check the [docs here](http://docs.peewee-orm.com/en/latest/peewee/querying.html#using-aggregate-rows) and scroll down to read the \"Some things to consider when using aggregate_rows():\" section.\n\n``` python\n# Note that we specify ordering for the first 3 tables. This is necessary due to the way\n# \"aggregate_rows\" progressively de-dupes data.\nsites = (HostedSite\n .select(HostedSite, HostedSitePage, HostedSitePageToType, ObjectType)\n .join(HostedSitePage, join_type=JOIN_LEFT_OUTER)\n .join(HostedSitePageToType, join_type=JOIN_LEFT_OUTER)\n .join(ObjectType, join_type=JOIN_LEFT_OUTER)\n .where(HostedSite.domain == domain)\n .order_by(HostedSite.domain, HostedSitePage.order_num, HostedSitePageToType.page))\nsite = sites.first()\n\nprint site.domain\n# Use the normal backref names.\nfor page in site.pages:\n print ' - ' + page.title\n for page_to_type in page.hostedsitepagetotype_set:\n print ' - ' + page_to_type.object_type.table_name\n```\n", "Thank you, `aggregate_rows()` seems to work.\n\nBtw, my `HostedSitePageToType` is a «through» table for the `ManyToManyField`. And it seems to be impossible to load this relationship eagerly.\n\n``` python\nHostedSitePage_Deferred = DeferredRelation()\n\nclass HostedSitePageToType(BaseModel):\n class Meta:\n db_table = \"hosted_site_page_to_type\"\n primary_key = False\n\n page = ForeignKeyField(HostedSitePage_Deferred)\n type = ForeignKeyField(ObjectType)\n\nclass HostedSitePage(BaseModel):\n class Meta:\n db_table = \"hosted_site_page\"\n\n id = PrimaryKeyField()\n path = CharField()\n title = CharField()\n text = TextField()\n order_num = IntegerField()\n\n site = ForeignKeyField(HostedSite, related_name=\"pages\")\n \"\"\" :type : HostedSite \"\"\"\n\n object_types = ManyToManyField(ObjectType, through_model=HostedSitePageToType)\n \"\"\" :type : List[ObjectType] \"\"\"\n\nHostedSitePage_Deferred.set_model(HostedSitePage)\n```\n\n> AttributeError: 'bool' object has no attribute 'name'\n", "Ohh... Now I tried to do the whole thing without `ManyToManyField`, and as far as I understand, Peewee doesn't support tables with `primary_key = False` id they are not the «through» tables?\n", "Yeah, everything works!\nSo, I stopped using `ManyToManyField`, instead I manually join table for the relationship.\n\n``` python\nclass HostedSitePage(BaseModel):\n class Meta:\n db_table = \"hosted_site_page\"\n\n id = PrimaryKeyField()\n path = CharField()\n title = CharField()\n text = TextField()\n order_num = IntegerField()\n\n site = ForeignKeyField(HostedSite, related_name=\"pages\")\n\n def object_types(self) -> List[ObjectType]:\n return [ptt.type for ptt in self._pagetotype_rels]\n\nclass HostedSitePageToType(BaseModel):\n class Meta:\n db_table = \"hosted_site_page_to_type\"\n primary_key = CompositeKey('page', 'type')\n\n page = ForeignKeyField(HostedSitePage, related_name=\"_pagetotype_rels\")\n type = ForeignKeyField(ObjectType)\n```\n", "You really should measure the performance of aggregate_rows vs prefetch....in every test I've done prefetch was faster. Aggregate rows can end up duplicating a ton of data, so if your db is on a network that's a lot of traffic.\n" ]
2016-03-16T14:21:15
2016-03-17T12:44:42
2016-03-17T07:05:05
CONTRIBUTOR
null
Hello. Please help me. I'm beginning to use Peewee for a project, and I don't understand how to make it eagerly load everything I need in the following situation. I have a model called HostedSite, which contains (one-to-many) zero or more HostedSitePage's, each of which is connected (many-to-many) with zero or more ObjectTypes, which can be thought of as classic tags. I thought the following should load everything I need in a single query, but it doesn't, and that's even without querying the tags: ``` python site = HostedSite.select(HostedSite, HostedSitePage, HostedSitePageToType, ObjectType)\ .join(HostedSitePage, join_type=JOIN_LEFT_OUTER)\ .join(HostedSitePageToType, join_type=JOIN_LEFT_OUTER)\ .join(ObjectType, join_type=JOIN_LEFT_OUTER)\ .where(HostedSite.domain == domain)\ .order_by(HostedSitePage.order_num)\ .first() # load just one site, but everything for it return site.pages[2].title ``` Here's what Peewee executes: ``` sql SELECT "t1"."company_id", "t1"."domain", "t1"."title", "t1"."is_active", "t4"."id", "t4"."path", "t4"."title", "t4"."text", "t4"."order_num", "t4"."site_id", "t2"."page_id", "t2"."type_id", "t3"."id", "t3"."tablename", "t3"."object_type_id" FROM "_a"."hosted_site" AS t1 LEFT OUTER JOIN "_a"."hosted_site_page" AS t4 ON ("t1"."company_id" = "t4"."site_id") LEFT OUTER JOIN "_a"."hosted_site_page_to_type" AS t2 ON ("t4"."id" = "t2"."page_id") LEFT OUTER JOIN "_a"."object_type_ids" AS t3 ON ("t2"."type_id" = "t3"."id") WHERE ("t1"."domain" = 'example.test') ORDER BY "t4"."order_num" ``` ``` sql SELECT "t1"."id", "t1"."name", "t1"."urname", "t1"."region_id", "t1"."is_locked", "t1"."email", "t1"."use_agent_billing" FROM "ml"."ml_company_all" AS t1 WHERE ("t1"."id" = 1) LIMIT 1 ``` ``` sql SELECT "t1"."id", "t1"."path", "t1"."title", "t1"."text", "t1"."order_num", "t1"."site_id" FROM "_a"."hosted_site_page" AS t1 WHERE ("t1"."site_id" = 1) ``` Okay, the second query seems to indicate some unrelated problem with my models, but what about the third one? Why is it executed, why doesn't Peewee load data from the result of the first query?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/888/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/888/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/887
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/887/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/887/comments
https://api.github.com/repos/coleifer/peewee/issues/887/events
https://github.com/coleifer/peewee/issues/887
140,601,108
MDU6SXNzdWUxNDA2MDExMDg=
887
does peewee support tormysql?
{ "login": "indoorwise", "id": 8873448, "node_id": "MDQ6VXNlcjg4NzM0NDg=", "avatar_url": "https://avatars.githubusercontent.com/u/8873448?v=4", "gravatar_id": "", "url": "https://api.github.com/users/indoorwise", "html_url": "https://github.com/indoorwise", "followers_url": "https://api.github.com/users/indoorwise/followers", "following_url": "https://api.github.com/users/indoorwise/following{/other_user}", "gists_url": "https://api.github.com/users/indoorwise/gists{/gist_id}", "starred_url": "https://api.github.com/users/indoorwise/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/indoorwise/subscriptions", "organizations_url": "https://api.github.com/users/indoorwise/orgs", "repos_url": "https://api.github.com/users/indoorwise/repos", "events_url": "https://api.github.com/users/indoorwise/events{/privacy}", "received_events_url": "https://api.github.com/users/indoorwise/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "I am not sure, but my guess is no. If you want some inspiration about implementing Peewee with event loops, check out https://github.com/05bit/peewee-async/blob/master/peewee_async.py\n" ]
2016-03-14T07:55:45
2016-03-14T13:22:32
2016-03-14T13:22:31
NONE
null
examples of peewee with mysql use pymysql,but this library is synchronized,tormysql is asynchoronized library, peewee can support it?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/887/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/887/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/886
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/886/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/886/comments
https://api.github.com/repos/coleifer/peewee/issues/886/events
https://github.com/coleifer/peewee/issues/886
140,453,937
MDU6SXNzdWUxNDA0NTM5Mzc=
886
count() doesn't work properly using UNION
{ "login": "tarot231", "id": 17806922, "node_id": "MDQ6VXNlcjE3ODA2OTIy", "avatar_url": "https://avatars.githubusercontent.com/u/17806922?v=4", "gravatar_id": "", "url": "https://api.github.com/users/tarot231", "html_url": "https://github.com/tarot231", "followers_url": "https://api.github.com/users/tarot231/followers", "following_url": "https://api.github.com/users/tarot231/following{/other_user}", "gists_url": "https://api.github.com/users/tarot231/gists{/gist_id}", "starred_url": "https://api.github.com/users/tarot231/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/tarot231/subscriptions", "organizations_url": "https://api.github.com/users/tarot231/orgs", "repos_url": "https://api.github.com/users/tarot231/repos", "events_url": "https://api.github.com/users/tarot231/events{/privacy}", "received_events_url": "https://api.github.com/users/tarot231/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Thank you, fixed.\n" ]
2016-03-13T06:16:34
2016-03-13T19:06:27
2016-03-13T19:06:09
NONE
null
Hello, following code currently doesn't work properly. ``` q = (q1 | q2) print(q.count()) ``` I tested to modify peewee.py as follows. ``` def count(self, clear_limit=False): if self._distinct or self._group_by or self._limit or self._offset or \ isinstance(self, CompoundSelect): return self.wrapped_count(clear_limit=clear_limit) ``` And then it went well. Please confirm whether this is right.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/886/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/886/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/885
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/885/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/885/comments
https://api.github.com/repos/coleifer/peewee/issues/885/events
https://github.com/coleifer/peewee/issues/885
140,393,125
MDU6SXNzdWUxNDAzOTMxMjU=
885
model_to_dict with DateField
{ "login": "alexpantyukhin", "id": 6513121, "node_id": "MDQ6VXNlcjY1MTMxMjE=", "avatar_url": "https://avatars.githubusercontent.com/u/6513121?v=4", "gravatar_id": "", "url": "https://api.github.com/users/alexpantyukhin", "html_url": "https://github.com/alexpantyukhin", "followers_url": "https://api.github.com/users/alexpantyukhin/followers", "following_url": "https://api.github.com/users/alexpantyukhin/following{/other_user}", "gists_url": "https://api.github.com/users/alexpantyukhin/gists{/gist_id}", "starred_url": "https://api.github.com/users/alexpantyukhin/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/alexpantyukhin/subscriptions", "organizations_url": "https://api.github.com/users/alexpantyukhin/orgs", "repos_url": "https://api.github.com/users/alexpantyukhin/repos", "events_url": "https://api.github.com/users/alexpantyukhin/events{/privacy}", "received_events_url": "https://api.github.com/users/alexpantyukhin/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "But `model_to_dict` doesn't do any json serialization?\n", "Sorry. found the reason it was another\n", "alexpantyukhin , what was the reason? I am having the same problem.\n", "model_to_dict returns a dict, not a JSON object, so I'm not sure what the confusion is about.\n", "Sorry, model_to_dict is working as expected. I am making a confusion here.\nI am trying to use json.dumps in a dictionary returned by model_to_dict, and it is failing (as expected).\nThe solution is not related to peewee code. \nSorry for this unnecessary message!\n" ]
2016-03-12T15:33:32
2016-03-31T21:29:43
2016-03-12T17:11:07
NONE
null
Hi! I have such model: ``` class User(BaseModel, UserMixin): birth_date = DateField(null=True) ...... ``` And when I try to do this: `model_to_dict(current_user)` I'm getting this error: TypeError: datetime.date(1989, 8, 9) is not JSON serializable
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/885/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/885/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/884
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/884/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/884/comments
https://api.github.com/repos/coleifer/peewee/issues/884/events
https://github.com/coleifer/peewee/issues/884
140,178,027
MDU6SXNzdWUxNDAxNzgwMjc=
884
SELECT FOUND_ROWS()
{ "login": "daoiqi", "id": 2141872, "node_id": "MDQ6VXNlcjIxNDE4NzI=", "avatar_url": "https://avatars.githubusercontent.com/u/2141872?v=4", "gravatar_id": "", "url": "https://api.github.com/users/daoiqi", "html_url": "https://github.com/daoiqi", "followers_url": "https://api.github.com/users/daoiqi/followers", "following_url": "https://api.github.com/users/daoiqi/following{/other_user}", "gists_url": "https://api.github.com/users/daoiqi/gists{/gist_id}", "starred_url": "https://api.github.com/users/daoiqi/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/daoiqi/subscriptions", "organizations_url": "https://api.github.com/users/daoiqi/orgs", "repos_url": "https://api.github.com/users/daoiqi/repos", "events_url": "https://api.github.com/users/daoiqi/events{/privacy}", "received_events_url": "https://api.github.com/users/daoiqi/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "use `wrapped_count()`\n\nhttp://docs.peewee-orm.com/en/latest/peewee/api.html#SelectQuery.wrapped_count\n" ]
2016-03-11T13:00:49
2016-03-11T14:32:55
2016-03-11T14:32:55
NONE
null
``` sql select * from t_table where id > 10; SELECT FOUND_ROWS(); ``` peewee has found rows ? need do it by self? ``` sql select * from t_table where id > 10 limit 10; select count(0) from t_table where id > 10; ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/884/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/884/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/883
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/883/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/883/comments
https://api.github.com/repos/coleifer/peewee/issues/883/events
https://github.com/coleifer/peewee/issues/883
139,855,726
MDU6SXNzdWUxMzk4NTU3MjY=
883
Building complex queries programmatically.
{ "login": "brijeshb42", "id": 717550, "node_id": "MDQ6VXNlcjcxNzU1MA==", "avatar_url": "https://avatars.githubusercontent.com/u/717550?v=4", "gravatar_id": "", "url": "https://api.github.com/users/brijeshb42", "html_url": "https://github.com/brijeshb42", "followers_url": "https://api.github.com/users/brijeshb42/followers", "following_url": "https://api.github.com/users/brijeshb42/following{/other_user}", "gists_url": "https://api.github.com/users/brijeshb42/gists{/gist_id}", "starred_url": "https://api.github.com/users/brijeshb42/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/brijeshb42/subscriptions", "organizations_url": "https://api.github.com/users/brijeshb42/orgs", "repos_url": "https://api.github.com/users/brijeshb42/repos", "events_url": "https://api.github.com/users/brijeshb42/events{/privacy}", "received_events_url": "https://api.github.com/users/brijeshb42/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "This type of question is not really appropriate for the peewee issue tracker.\n" ]
2016-03-10T11:05:04
2016-03-10T14:21:45
2016-03-10T14:21:45
NONE
null
This is not an issue but a question. I have to build complex queries programmatically. For ex: For this model: ``` python class Article(Model): title = CharField(null=False, unique=False, index=True) permalink = CharField(default=None, unique=True, null=True) tags = ArrayField(CharField, null=True, default=[], index=True) keywords = ArrayField(CharField, null=True, default=[], index=False) summary = TextField(null=True) content = TextField(default='') series_id = IntegerField(default=0, index=True) ``` Through an API request on web, I will receive the filter like this, ``` json { "fields_wanted": ["title", "permalink", "summary"], "series_id": [1, 2] } ``` Through the above post request data, I basically want to generate this query: ``` python articles = Article.select(Article.title, Article.permalink, Article.summary).where( Article.series_id.in_(1, 2)).execute() ``` I was thinking to generate like this (after validating the json): ``` python fields = [getattr(Article, field) for field in post_data["fields_wanted"]] articles = Article.select(fields).where( getattr(Article, "series_id").in_(data["series_id"])).execute() ``` Is this a good way or can it be implemented in some other way? How would I go about doing the above?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/883/reactions", "total_count": 2, "+1": 2, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/883/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/882
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/882/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/882/comments
https://api.github.com/repos/coleifer/peewee/issues/882/events
https://github.com/coleifer/peewee/issues/882
139,767,814
MDU6SXNzdWUxMzk3Njc4MTQ=
882
Compound searches
{ "login": "samizdis", "id": 11559853, "node_id": "MDQ6VXNlcjExNTU5ODUz", "avatar_url": "https://avatars.githubusercontent.com/u/11559853?v=4", "gravatar_id": "", "url": "https://api.github.com/users/samizdis", "html_url": "https://github.com/samizdis", "followers_url": "https://api.github.com/users/samizdis/followers", "following_url": "https://api.github.com/users/samizdis/following{/other_user}", "gists_url": "https://api.github.com/users/samizdis/gists{/gist_id}", "starred_url": "https://api.github.com/users/samizdis/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/samizdis/subscriptions", "organizations_url": "https://api.github.com/users/samizdis/orgs", "repos_url": "https://api.github.com/users/samizdis/repos", "events_url": "https://api.github.com/users/samizdis/events{/privacy}", "received_events_url": "https://api.github.com/users/samizdis/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "One way to accomplish the \"posts without badtag\" might be:\n\n``` python\n(Post\n .select()\n .where(~fn.EXISTS(\n Tag.select().where(\n (Tag.post == Post.id) & (Tag.name == 'BadTag'))))\n```\n\nAnother might be:\n\n``` python\n(Post\n .select(Post, fn.COUNT(Tag.id))\n .join(Tag, JOIN.LEFT_OUTER)\n .where(Tag.name == 'BadTag')\n .group_by(Post)\n .having(fn.COUNT(Tag.id) == 0))\n```\n\nI didn't test these examples, but hopefully you get the idea.\n" ]
2016-03-10T02:49:39
2016-03-10T14:19:15
2016-03-10T14:19:15
NONE
null
``` select * from post t1 where not exists (select 1 from tag t2 where t1.id == t2.post_id and t2.name=='BadTag'); ``` finds all posts which haven't any associated tags named 'BadTag'. Is there a way to do this naturally in Peewee? ``` Post.select().where( ~Tag.select() .where(Post.id == Tag.post & Tag.name=='BadTag') .exists() ) ``` gets compiled to `SELECT "t1"."id", ... FROM "post" AS t1 WHERE ? [-1]` and `Post.select().join(Tag).where(Tag.name!='BadTag')` doesn't work since a Post can have many Tags. I can use `Post.raw()` but then can't do things like `.order_by()`
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/882/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/882/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/881
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/881/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/881/comments
https://api.github.com/repos/coleifer/peewee/issues/881/events
https://github.com/coleifer/peewee/issues/881
139,588,378
MDU6SXNzdWUxMzk1ODgzNzg=
881
Key Error where query jsonb in postgresql with peewee
{ "login": "bukun", "id": 6925146, "node_id": "MDQ6VXNlcjY5MjUxNDY=", "avatar_url": "https://avatars.githubusercontent.com/u/6925146?v=4", "gravatar_id": "", "url": "https://api.github.com/users/bukun", "html_url": "https://github.com/bukun", "followers_url": "https://api.github.com/users/bukun/followers", "following_url": "https://api.github.com/users/bukun/following{/other_user}", "gists_url": "https://api.github.com/users/bukun/gists{/gist_id}", "starred_url": "https://api.github.com/users/bukun/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/bukun/subscriptions", "organizations_url": "https://api.github.com/users/bukun/orgs", "repos_url": "https://api.github.com/users/bukun/repos", "events_url": "https://api.github.com/users/bukun/events{/privacy}", "received_events_url": "https://api.github.com/users/bukun/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "I have tried with Python 2.7 and Python 3.5.\n", "Are you absolutely positive that your model class is using `PostgresqlExtDatabase` as it's database class?\n", "Greate! thanks very much. I have tried several time, and could not find any information with google.\nshould be:\n\n```\nfrom playhouse.postgres_ext import PostgresqlExtDatabase\ndbconnect = PostgresqlExtDatabase(\n```\n" ]
2016-03-09T14:18:40
2016-03-09T14:43:53
2016-03-09T14:43:38
NONE
null
I'm user peewee for PostgreSQL query with Python 3.5 under Debian Jessis. Everythin goes well untill querying Jsonb field. The script: ``` import peewee from playhouse.postgres_ext import BinaryJSONField dbconnect = peewee.PostgresqlDatabase( 'pycate', user='yunsuan', password='passhere', host='127.0.0.1', autocommit=True, autorollback=True ) class BaseModel(peewee.Model): class Meta: database = dbconnect class TestTabInfor(BaseModel): uid = peewee.CharField(null=False, index=True, unique=True, primary_key=True, max_length=36, help_text='', ) title = peewee.CharField(null=False, default='') infor = BinaryJSONField() try: TestTabInfor.create_table() except: pass condition = {} db_data = (TestTabInfor .select() .where(TestTabInfor.infor.contains(condition))) print(db_data) ``` It will echo: `KeyError: 'JB@>'`
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/881/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/881/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/880
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/880/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/880/comments
https://api.github.com/repos/coleifer/peewee/issues/880/events
https://github.com/coleifer/peewee/issues/880
139,432,472
MDU6SXNzdWUxMzk0MzI0NzI=
880
Handling of extra fields during create and insert
{ "login": "poliquin", "id": 360123, "node_id": "MDQ6VXNlcjM2MDEyMw==", "avatar_url": "https://avatars.githubusercontent.com/u/360123?v=4", "gravatar_id": "", "url": "https://api.github.com/users/poliquin", "html_url": "https://github.com/poliquin", "followers_url": "https://api.github.com/users/poliquin/followers", "following_url": "https://api.github.com/users/poliquin/following{/other_user}", "gists_url": "https://api.github.com/users/poliquin/gists{/gist_id}", "starred_url": "https://api.github.com/users/poliquin/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/poliquin/subscriptions", "organizations_url": "https://api.github.com/users/poliquin/orgs", "repos_url": "https://api.github.com/users/poliquin/repos", "events_url": "https://api.github.com/users/poliquin/events{/privacy}", "received_events_url": "https://api.github.com/users/poliquin/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "> Is there a reason for Model.create to ignore \"extra\" keyword arguments and for Model.insert to throw an error?\n\nIt's just an oversight on my part. At present, I am not inclined to change this as people may have code that relies on the behavior of `create()`. Additionally, `create()` is a bit semantically different than `insert()`....so I think I'm going to leave this as wontfix.\n", "> I prefer the behavior of ignoring keys without corresponding model fields\n\nOut of curiosity, @poliquin, what is your use case for that feature? I always thought I prefer the opposite and rather throw an error when trying to assign values to non-existent fields.\n", "@tuukkamustonen, I find it useful when processing messy CSV data with fields that change slightly from file to file and have many uninteresting columns. I frequently encounter data like this from government sources. I read all data with `csv.DictReader`, transform fields to have consistent names matching my schema (e.g. lowercase, no spaces, ....), then simply pass the keyword arguments to `Model.create` with the `**` syntax. The stuff I want gets loaded, and the junk is ignored.\n\nI definitely see the logic in throwing errors when encountering unexpected inputs, however, which is probably why the default `csv.DictWriter` behavior is `extrasaction='raise'`.\n" ]
2016-03-09T00:08:06
2016-03-09T22:15:57
2016-03-09T14:44:04
NONE
null
The `create` and `insert` methods of `Model` treat extra keys differently. The following toy example demonstrates what I mean: ``` python from peewee import Model, SqliteDatabase, IntegerField db = SqliteDatabase(':memory:') class ToyModel(Model): x = IntegerField() y = IntegerField() class Meta: database = db db_table = 'toys' db.create_table(ToyModel, safe=True) # insert some data, notice the extra 'z' key is ignored data = {'x': 2, 'y': 4, 'z': 1} m = ToyModel.create(**data) m.save() # no error here # show that it worked assert [(t.x, t.y) for t in ToyModel.select()] == [(2, 4)] # insert some data, raises a KeyError for 'z' ToyModel.insert(**data).execute() ``` `Model.insert` looks for each key in `cls._meta.fields`, but `create` and `__init__` simply iterate over the keywords and assign attributes for everything, regardless of whether there is an actual field in the model. I prefer the behavior of ignoring keys without corresponding model fields (i.e. making `insert` consistent with `create`), but Python's `csv.DictWriter` is an example of allowing both behaviors via the `extrasaction` argument. Perhaps `peewee` could use a similar interface? Is there a reason for `Model.create` to ignore "extra" keyword arguments and for `Model.insert` to throw an error?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/880/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/880/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/879
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/879/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/879/comments
https://api.github.com/repos/coleifer/peewee/issues/879/events
https://github.com/coleifer/peewee/issues/879
138,798,894
MDU6SXNzdWUxMzg3OTg4OTQ=
879
Missing implementation of __hash__ in Model
{ "login": "kramer65", "id": 596581, "node_id": "MDQ6VXNlcjU5NjU4MQ==", "avatar_url": "https://avatars.githubusercontent.com/u/596581?v=4", "gravatar_id": "", "url": "https://api.github.com/users/kramer65", "html_url": "https://github.com/kramer65", "followers_url": "https://api.github.com/users/kramer65/followers", "following_url": "https://api.github.com/users/kramer65/following{/other_user}", "gists_url": "https://api.github.com/users/kramer65/gists{/gist_id}", "starred_url": "https://api.github.com/users/kramer65/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/kramer65/subscriptions", "organizations_url": "https://api.github.com/users/kramer65/orgs", "repos_url": "https://api.github.com/users/kramer65/repos", "events_url": "https://api.github.com/users/kramer65/events{/privacy}", "received_events_url": "https://api.github.com/users/kramer65/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[]
2016-03-06T15:03:47
2016-03-06T15:31:04
2016-03-06T15:31:04
NONE
null
I'm using peewee in several of my projects, and I love it. Today I found a weird behaviour of testing whether models already exist in a dict. I asked a question about it on Stackoverflow: http://stackoverflow.com/questions/35826534/object-in-list-behaves-different-from-object-in-dict [The answer](http://stackoverflow.com/a/35826785/1650012) turns out to be that the object (in this case an instance of a Model which I got from a peewee `select()`) doesn't seem to implement `__hash__` so it instead uses the “bad hash implementation” (which is based on the object id) as the default. I solved my trouble with al little workaround by using `if theObject in list(theDict)`, which makes use of the `__eq__` method instead of the `__hash__` method. I just wanted to let you guys know of this small issue though, so when you have time you can check whether you can add an implementation of the `__hash__` method to Model. Cheers, and thanks for creating peewee!
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/879/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/879/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/878
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/878/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/878/comments
https://api.github.com/repos/coleifer/peewee/issues/878/events
https://github.com/coleifer/peewee/issues/878
138,068,574
MDU6SXNzdWUxMzgwNjg1NzQ=
878
limit(0) has no effect
{ "login": "ameade", "id": 847570, "node_id": "MDQ6VXNlcjg0NzU3MA==", "avatar_url": "https://avatars.githubusercontent.com/u/847570?v=4", "gravatar_id": "", "url": "https://api.github.com/users/ameade", "html_url": "https://github.com/ameade", "followers_url": "https://api.github.com/users/ameade/followers", "following_url": "https://api.github.com/users/ameade/following{/other_user}", "gists_url": "https://api.github.com/users/ameade/gists{/gist_id}", "starred_url": "https://api.github.com/users/ameade/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/ameade/subscriptions", "organizations_url": "https://api.github.com/users/ameade/orgs", "repos_url": "https://api.github.com/users/ameade/repos", "events_url": "https://api.github.com/users/ameade/events{/privacy}", "received_events_url": "https://api.github.com/users/ameade/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[]
2016-03-03T03:56:53
2016-03-03T15:19:23
2016-03-03T15:19:23
NONE
null
When doing for example 'User.select().limit(0)' all users will be returned. Changing the 0 to a positive integer seems to work correctly and a negative integer raises an error as expected. This is frustrating when programmatically calculated limit and expecting limit(0) to work as 'LIMIT 0' is valid sql.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/878/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/878/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/877
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/877/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/877/comments
https://api.github.com/repos/coleifer/peewee/issues/877/events
https://github.com/coleifer/peewee/issues/877
138,002,020
MDU6SXNzdWUxMzgwMDIwMjA=
877
Playhouse speedups
{ "login": "stanep", "id": 3240661, "node_id": "MDQ6VXNlcjMyNDA2NjE=", "avatar_url": "https://avatars.githubusercontent.com/u/3240661?v=4", "gravatar_id": "", "url": "https://api.github.com/users/stanep", "html_url": "https://github.com/stanep", "followers_url": "https://api.github.com/users/stanep/followers", "following_url": "https://api.github.com/users/stanep/following{/other_user}", "gists_url": "https://api.github.com/users/stanep/gists{/gist_id}", "starred_url": "https://api.github.com/users/stanep/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/stanep/subscriptions", "organizations_url": "https://api.github.com/users/stanep/orgs", "repos_url": "https://api.github.com/users/stanep/repos", "events_url": "https://api.github.com/users/stanep/events{/privacy}", "received_events_url": "https://api.github.com/users/stanep/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Just pass `use_speedups=False` when you are instantiating your Database object. That should address the issue. Peewee implements some cursor iteration helpers in Cython and expects the rows to be tuples, hence the issue you're seeing.\n\nLet me know if the above fix addresses the problem.\n", "Yes this fix the problem, thx\n" ]
2016-03-02T21:46:16
2016-03-03T14:17:46
2016-03-03T14:17:46
NONE
null
Hi, using a new peewee (2.8.0) (pip install -U peewee) I got compiled playhouse._speedups file. Now I am using SQL Server 2012 and pyodbc with peewee and so far it works but when I install latest version I got error running simple select statements. File "\playhouse\speedups.pyx", line 179, in playhouse._speedups._QueryResultWrapper.iterate (playhouse\speedups.c:3690) TypeError: expected tuple, got pyodbc.Row If I rename _speedupds file I peewee works , so not sure if this is a bug, but maybe you can do something so speedups will work with pyodbc :)
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/877/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/877/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/876
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/876/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/876/comments
https://api.github.com/repos/coleifer/peewee/issues/876/events
https://github.com/coleifer/peewee/issues/876
137,627,410
MDU6SXNzdWUxMzc2Mjc0MTA=
876
default_index cannot be None in IndexedFieldMixin
{ "login": "IxDay", "id": 2128384, "node_id": "MDQ6VXNlcjIxMjgzODQ=", "avatar_url": "https://avatars.githubusercontent.com/u/2128384?v=4", "gravatar_id": "", "url": "https://api.github.com/users/IxDay", "html_url": "https://github.com/IxDay", "followers_url": "https://api.github.com/users/IxDay/followers", "following_url": "https://api.github.com/users/IxDay/following{/other_user}", "gists_url": "https://api.github.com/users/IxDay/gists{/gist_id}", "starred_url": "https://api.github.com/users/IxDay/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/IxDay/subscriptions", "organizations_url": "https://api.github.com/users/IxDay/orgs", "repos_url": "https://api.github.com/users/IxDay/repos", "events_url": "https://api.github.com/users/IxDay/events{/privacy}", "received_events_url": "https://api.github.com/users/IxDay/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "This is fixed by 2fca64c482f536f280303a77fe8e9c040a0c96b3\n\nTo indicate that there should be no index, simply specify `index=False` when instantiating your `ArrayField`.\n", "(the same goes for any other field that mixes in `IndexedFieldMixin`.)\n", "Great thanks !\n", "Thanks for reporting the issue, I appreciate it!\n" ]
2016-03-01T16:47:57
2016-03-13T19:53:58
2016-03-13T19:25:43
NONE
null
As in the constructor we setup the index like this: https://github.com/coleifer/peewee/blob/master/playhouse/postgres_ext.py#L129 ``` python self.index_type = index_type or self.default_index_type ``` I cannot specify at Field declaration that I do not want any index, as if I explicitly define `index_type` to be None it will be overridden by the previous line. I think a better way to handle this can be to wrote the code like this: ``` python class IndexedFieldMixin(object): def __init__(self, index_type='GiST', *args, **kwargs): kwargs.setdefault('index', True) # By default, use an index. super(IndexedFieldMixin, self).__init__(*args, **kwargs) self.index_type = index_type class ArrayField(IndexedFieldMixin, Field): def __init__(self, field_class=IntegerField, dimensions=1, index_type='GIN', *args, **kwargs): self.__field = field_class(*args, **kwargs) self.dimensions = dimensions self.db_field = self.__field.get_db_field() super(ArrayField, self).__init__(*args, **kwargs) ... ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/876/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/876/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/875
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/875/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/875/comments
https://api.github.com/repos/coleifer/peewee/issues/875/events
https://github.com/coleifer/peewee/issues/875
137,208,995
MDU6SXNzdWUxMzcyMDg5OTU=
875
Create type
{ "login": "IxDay", "id": 2128384, "node_id": "MDQ6VXNlcjIxMjgzODQ=", "avatar_url": "https://avatars.githubusercontent.com/u/2128384?v=4", "gravatar_id": "", "url": "https://api.github.com/users/IxDay", "html_url": "https://github.com/IxDay", "followers_url": "https://api.github.com/users/IxDay/followers", "following_url": "https://api.github.com/users/IxDay/following{/other_user}", "gists_url": "https://api.github.com/users/IxDay/gists{/gist_id}", "starred_url": "https://api.github.com/users/IxDay/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/IxDay/subscriptions", "organizations_url": "https://api.github.com/users/IxDay/orgs", "repos_url": "https://api.github.com/users/IxDay/repos", "events_url": "https://api.github.com/users/IxDay/events{/privacy}", "received_events_url": "https://api.github.com/users/IxDay/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Unfortunately, you'll need to call `register_fields` to use custom types:\n\n``` python\nclass DirectionField(...):\n db_type = 'direction'\n\nPostgresqlDatabase.register_fields({\n 'direction': 'direction',\n})\n```\n\nHope to get rid/clean-up that boiler plate in a later version of peewee but for now it is required.\n" ]
2016-02-29T10:12:48
2016-02-29T12:40:30
2016-02-29T12:40:30
NONE
null
As I use custom types, is there a way to perform this in peewee or do I have to add a create_type method in the QueryCompiler class? If so, are you interested in the implementation of this feature ? Here is an example of the code I use ``` sql CREATE TYPE direction AS (title varchar(50), text text); ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/875/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/875/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/874
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/874/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/874/comments
https://api.github.com/repos/coleifer/peewee/issues/874/events
https://github.com/coleifer/peewee/issues/874
137,098,485
MDU6SXNzdWUxMzcwOTg0ODU=
874
peewee.OperationalError: database is locked using threadlocals and SqliteDatabase
{ "login": "cryzed", "id": 1429103, "node_id": "MDQ6VXNlcjE0MjkxMDM=", "avatar_url": "https://avatars.githubusercontent.com/u/1429103?v=4", "gravatar_id": "", "url": "https://api.github.com/users/cryzed", "html_url": "https://github.com/cryzed", "followers_url": "https://api.github.com/users/cryzed/followers", "following_url": "https://api.github.com/users/cryzed/following{/other_user}", "gists_url": "https://api.github.com/users/cryzed/gists{/gist_id}", "starred_url": "https://api.github.com/users/cryzed/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/cryzed/subscriptions", "organizations_url": "https://api.github.com/users/cryzed/orgs", "repos_url": "https://api.github.com/users/cryzed/repos", "events_url": "https://api.github.com/users/cryzed/events{/privacy}", "received_events_url": "https://api.github.com/users/cryzed/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "I'm almost sure I fixed the problem [here](https://github.com/cryzed/Feedbuffer/commit/3b29434de92c8d0c47b90761858239ee1df08cd8). I'm just speculating, but I think the problem arose because I created the CherryPy server object in a [different thread](https://github.com/cryzed/Feedbuffer/commit/3b29434de92c8d0c47b90761858239ee1df08cd8#diff-5bc02cefb3ea9e27f1a6776eabd1935dL20) (main thread) instead of within the spawned thread. I also had to change the generator expression [here](https://github.com/cryzed/Feedbuffer/commit/3b29434de92c8d0c47b90761858239ee1df08cd8#diff-91c7a2706bca60a3f59aefad6b396b0eL32).\n\nNow everything works without issues and it's reproducible -- reverting those changes leads to the aforementioned problems again and even slows everything down considerably. In the end I think it might be, because I am passing objects not local to the thread around, but I'd be lying if I said that I knew exactly what's going on. Maybe you have some input?\n\nThanks for peewee,\nChris\n", "I'm not sure about your application or anything specifically you may be encountering, but what I can tell you is:\n- sqlite enforces a _global database lock_ when you write to the db.\n- multi-threaded apps need to be careful about serializing writes or correctly handling \"busy\" errors.\n- using peewee with threadsafe=True is the default for a long time. all it means is you get a connection per thread, but those threads/connections can still contend for write locks.\n" ]
2016-02-28T21:35:09
2016-02-29T01:50:01
2016-02-29T01:50:01
NONE
null
Hey, I recently made this: [Feedbuffer](https://github.com/cryzed/Feedbuffer) and decided to use peewee for the database interface. I know it's not really your task to review my code, but I feel my problem would be easiest to explain if I linked you the file that manages the database communication [here](https://github.com/cryzed/Feedbuffer/blob/master/feedbuffer/database.py). The thread architecture of the whole thing looks as follows: A CherryPy (webserver) instance is started in its own thread, which may spawn more threads (IIRC up to 10 more in the default configuration) to handle requests. Additionally I am using a ThreadPoolExecutor with 5 up to 40 workers, depending on the system the script is running on. The problem occurs when I try to update many new feeds at once by using my RSS reader (imagine ~200 feeds with 10~ connections asking for updates). What puzzles me is that I am getting a "database is locked" error -- I was under the assumption that this could be entirely avoided by using `threadlocals=True` and instructing peewee with that to manage a single connection per thread. Am I doing something in my code that would require this mechanism to fail? Are those too many threads for sqlite to handle? Some advice would be great.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/874/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/874/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/873
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/873/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/873/comments
https://api.github.com/repos/coleifer/peewee/issues/873/events
https://github.com/coleifer/peewee/issues/873
137,051,683
MDU6SXNzdWUxMzcwNTE2ODM=
873
get_or_create without autocommit
{ "login": "Gagaro", "id": 3845486, "node_id": "MDQ6VXNlcjM4NDU0ODY=", "avatar_url": "https://avatars.githubusercontent.com/u/3845486?v=4", "gravatar_id": "", "url": "https://api.github.com/users/Gagaro", "html_url": "https://github.com/Gagaro", "followers_url": "https://api.github.com/users/Gagaro/followers", "following_url": "https://api.github.com/users/Gagaro/following{/other_user}", "gists_url": "https://api.github.com/users/Gagaro/gists{/gist_id}", "starred_url": "https://api.github.com/users/Gagaro/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/Gagaro/subscriptions", "organizations_url": "https://api.github.com/users/Gagaro/orgs", "repos_url": "https://api.github.com/users/Gagaro/repos", "events_url": "https://api.github.com/users/Gagaro/events{/privacy}", "received_events_url": "https://api.github.com/users/Gagaro/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "It creates an exception (or savepoint, if a transaction is present) to ensure the connection can be restored to a good state after an IntegrityError. Postgres, for instance, is rather unforgiving regarding this.\n\nI'll add something to the docs, but for now I don't really see this as a bug.\n", "In your example code, is there a reason you're not using the `atomic()` context manager / decorator? The `atomic()` helper will manage a stack of transactions/savepoints behind-the-scenes.\n", "> In your example code, is there a reason you're not using the atomic() context manager / decorator?\n\nI was reproducing my use case. It indeed works with atomic, but I can't use it for what I want to do.\n\nShouldn't atomic then also create a savepoint rather than create a new transaction when inside a begin ?\n", "So I was able to have something working with the following:\n\n``` python\nself._transaction = db.transaction()\nself._transaction.__enter__()\n# [...]\nself._transaction.__exit__(True, None, None)\n```\n\nIt isn't very intuitive though.\n", "Yeah, atomic will create a savepoint if there is a transaction in progress.\n\nYou can write your own `get_or_create()` that doesn't use a transaction/savepoint. Or you can use a decorator/context manager to manage your explicit transactions.\n" ]
2016-02-28T13:12:29
2016-02-29T12:38:45
2016-02-29T02:00:00
NONE
null
Hello, `get_or_create` and `create_or_get` fails if autocommit is set to False due to the use of a transaction inside these methods: https://github.com/coleifer/peewee/blob/master/peewee.py#L4562 https://github.com/coleifer/peewee/blob/master/peewee.py#L4573 I created a test demonstrating this issue: https://github.com/Gagaro/peewee/commit/cb64cce3e473187bc4284357941185088b3de57b Also only these two methods create a transaction. Why is a transaction needed here? Thanks
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/873/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/873/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/872
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/872/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/872/comments
https://api.github.com/repos/coleifer/peewee/issues/872/events
https://github.com/coleifer/peewee/issues/872
136,817,508
MDU6SXNzdWUxMzY4MTc1MDg=
872
Query Error using APSW
{ "login": "mox1", "id": 6137131, "node_id": "MDQ6VXNlcjYxMzcxMzE=", "avatar_url": "https://avatars.githubusercontent.com/u/6137131?v=4", "gravatar_id": "", "url": "https://api.github.com/users/mox1", "html_url": "https://github.com/mox1", "followers_url": "https://api.github.com/users/mox1/followers", "following_url": "https://api.github.com/users/mox1/following{/other_user}", "gists_url": "https://api.github.com/users/mox1/gists{/gist_id}", "starred_url": "https://api.github.com/users/mox1/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/mox1/subscriptions", "organizations_url": "https://api.github.com/users/mox1/orgs", "repos_url": "https://api.github.com/users/mox1/repos", "events_url": "https://api.github.com/users/mox1/events{/privacy}", "received_events_url": "https://api.github.com/users/mox1/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "0e055df5317e9966831b760a5a2aa8990f759207\n", "Thank you for the excellent bug report, this should now be fixed.\n", "You may need to update your apsw version, because in the latest versions it _does_ support `fetchone()`. I had to revert my commit that fixed the issue, due to MySQL python driver not implementing the iterator protocol on its cursor... Anyways, just try upgrading apsw and you should be set!\n" ]
2016-02-26T21:20:42
2016-02-29T03:42:47
2016-02-27T17:28:14
NONE
null
When using the apsw_ext module, I receive the following error when performing queries: ``` >>> x = SomeModel.select().where(SomeModel.col1 == "test").exists() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "peewee.py", line 2896, in exists return bool(clone.scalar()) File "peewee.py", line 2653, in scalar row = self._execute().fetchone() AttributeError: 'apsw.Cursor' object has no attribute 'fetchone' ``` I see references in older versions of the code implementing a 'fetchone()' that calls next(), because APSW isn't DB-API compliant. Somewhere this code appears to have been re-factored out. This is using the trivial example model from the Docs ``` db = APSWDatabase(':memory:') class BaseModel(Model): class Meta: database = db class SomeModel(BaseModel): col1 = CharField() col2 = DateTimeField() ``` python 2.7.6 On Ubuntu 14.04 Using peewee 2.8.0 (git rev 4c1db1399c0906ea3ac59448fa4a333e813098fa) Using python-apsw 3.8.2-r1-1ubuntu1
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/872/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/872/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/871
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/871/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/871/comments
https://api.github.com/repos/coleifer/peewee/issues/871/events
https://github.com/coleifer/peewee/issues/871
136,738,698
MDU6SXNzdWUxMzY3Mzg2OTg=
871
Problem with pymysql + python 2.7
{ "login": "foxx", "id": 651797, "node_id": "MDQ6VXNlcjY1MTc5Nw==", "avatar_url": "https://avatars.githubusercontent.com/u/651797?v=4", "gravatar_id": "", "url": "https://api.github.com/users/foxx", "html_url": "https://github.com/foxx", "followers_url": "https://api.github.com/users/foxx/followers", "following_url": "https://api.github.com/users/foxx/following{/other_user}", "gists_url": "https://api.github.com/users/foxx/gists{/gist_id}", "starred_url": "https://api.github.com/users/foxx/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/foxx/subscriptions", "organizations_url": "https://api.github.com/users/foxx/orgs", "repos_url": "https://api.github.com/users/foxx/repos", "events_url": "https://api.github.com/users/foxx/events{/privacy}", "received_events_url": "https://api.github.com/users/foxx/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "I'm not quite sure I understand... what's going on here?\n", "Sorry here's an exact code snippet to reproduce the problem with `pymysql` and `python 2.7.11`.\n\nThe same code works as expected with `sqlite` and `postgres`.\n\n``` python\nfrom peewee import BlobField, Model\nfrom playhouse.db_url import connect\n\ndb = connect('mysql://[email protected]/peewee_test')\n\nclass ExampleModel(Model):\n class Meta:\n database = db\n value = BlobField()\n\nExampleModel.drop_table()\nExampleModel.create_table()\nExampleModel.create(value='1234')\n```\n\nResult;\n\n```\n$ python hello.py\nTraceback (most recent call last):\n File \"hello.py\", line 13, in <module>\n ExampleModel.create(value='1234')\n File \"/home/vagrant/.pyenv/versions/2.7.11/lib/python2.7/site-packages/peewee.py\", line 4494, in create\n inst.save(force_insert=True)\n File \"/home/vagrant/.pyenv/versions/2.7.11/lib/python2.7/site-packages/peewee.py\", line 4680, in save\n pk_from_cursor = self.insert(**field_dict).execute()\n File \"/home/vagrant/.pyenv/versions/2.7.11/lib/python2.7/site-packages/peewee.py\", line 3213, in execute\n cursor = self._execute()\n File \"/home/vagrant/.pyenv/versions/2.7.11/lib/python2.7/site-packages/peewee.py\", line 2628, in _execute\n return self.database.execute_sql(sql, params, self.require_commit)\n File \"/home/vagrant/.pyenv/versions/2.7.11/lib/python2.7/site-packages/peewee.py\", line 3454, in execute_sql\n cursor.execute(sql, params or ())\n File \"/home/vagrant/.pyenv/versions/2.7.11/lib/python2.7/site-packages/pymysql/cursors.py\", line 156, in execute\n query = self.mogrify(query, args)\n File \"/home/vagrant/.pyenv/versions/2.7.11/lib/python2.7/site-packages/pymysql/cursors.py\", line 135, in mogrify\n query = query % self._escape_args(args, conn)\n File \"/home/vagrant/.pyenv/versions/2.7.11/lib/python2.7/site-packages/pymysql/cursors.py\", line 110, in _escape_args\n return tuple(conn.escape(arg) for arg in args)\n File \"/home/vagrant/.pyenv/versions/2.7.11/lib/python2.7/site-packages/pymysql/cursors.py\", line 110, in <genexpr>\n return tuple(conn.escape(arg) for arg in args)\n File \"/home/vagrant/.pyenv/versions/2.7.11/lib/python2.7/site-packages/pymysql/connections.py\", line 781, in escape\n return escape_item(obj, self.charset, mapping=mapping)\n File \"/home/vagrant/.pyenv/versions/2.7.11/lib/python2.7/site-packages/pymysql/converters.py\", line 26, in escape_item\n val = encoder(val, mapping)\n File \"/home/vagrant/.pyenv/versions/2.7.11/lib/python2.7/site-packages/pymysql/converters.py\", line 109, in escape_unicode\n return u\"'%s'\" % _escape_unicode(value)\n File \"/home/vagrant/.pyenv/versions/2.7.11/lib/python2.7/site-packages/pymysql/converters.py\", line 72, in _escape_unicode\n return value.translate(_escape_table)\nAttributeError: 'buffer' object has no attribute 'translate'\n```\n", "This should be fixed. The `BlobField` will now use the database-drivers `Binary` column type.\n\nb32e967e933c0d9d029f3385a5a115c46beacd03\n", "Awesome, I'll let you know if I run into any problems, thanks for the quick response!\n", "I am getting a similar error:\n\n```\n/vagrant/data/ida_generate_trace.py: 'buffer' object has no attribute 'translate'\n\nFile \"/vagrant/data/trace_to_db.py\", line 59, in add_initial_memory_areas_to_trace\n peewee_memory_area.save()\n File \"/opt/Python2.7-32bit/lib/python2.7/site-packages/peewee.py\", line 4680, in save\n pk_from_cursor = self.insert(**field_dict).execute()\n File \"/opt/Python2.7-32bit/lib/python2.7/site-packages/peewee.py\", line 3213, in execute\n cursor = self._execute()\n File \"/opt/Python2.7-32bit/lib/python2.7/site-packages/peewee.py\", line 2628, in _execute\n return self.database.execute_sql(sql, params, self.require_commit)\n```\n\nThe memory area looks like this:\n\n```\nclass MemoryArea(Model):\n trace = ForeignKeyField(Trace, related_name='initial_memory_areas')\n start_addr = BigIntegerField()\n size = BigIntegerField()\n memory_content = BlobField(null=True)\n\n class Meta:\n database = db\n```\n\nI am using `MySQLDatabase`.\n\nIs this the same issue? I installed peewee via pip. It says version \n\n> 2.8.0\n", "BTW: If I change the db to `SqliteDatabase`, I am getting a different error\n\n```\n/vagrant/data/ida_generate_trace.py: Python int too large to convert to SQLite INTEGER\nTraceback (most recent call last):\n [...]\n peewee_memory_area.save()\n File \"/opt/Python2.7-32bit/lib/python2.7/site-packages/peewee.py\", line 4680, in save\n pk_from_cursor = self.insert(**field_dict).execute()\n File \"/opt/Python2.7-32bit/lib/python2.7/site-packages/peewee.py\", line 3213, in execute\n cursor = self._execute()\n File \"/opt/Python2.7-32bit/lib/python2.7/site-packages/peewee.py\", line 2628, in _execute\n return self.database.execute_sql(sql, params, self.require_commit)\n```\n", "Looks like the same problem, although you're getting a different error with Sqlite because it's passing the driver layer and actually executing the SQ (afaik), and I think the most recent patch in master might not resolve this issue (as that relates to blob fields only from what I can tell)\n\n/cc @coleifer Any update on that new release? :P\n", "The SQLite one may be related to the integer fields as far as I can tell from the traceback. SQLite doesn't have a big integer field, so you may need to store those as text.\n", "Prob need a new release to fix the blob thing, though, as @foxx said. I'll try and get one together soon\n", "Thank you. I would really appreciate it. I like peewee and would like to use it for my current project, and future ones.  For the moment, I am kind of stuck with this bug. \n\nSent from Outlook Mobile\n", "You can always point at master, but I understand what you're saying and will try and get this done tonight.\n", "@coleifer Happy to throw a pair of hands on this, if there's anything I can do to help (testing, docs or w/e)\n", "@gitttt If you're really stuck and not sure how to install from master, let me know and I'll post some instructions up for you.\n", "Oh, I did not understand you correctly. So you have fixed this problem already? I will try to point at master and check if it works.\n", "I re-installed peewee. This time from the github repo. The error is gone.\n", "I got the same error.\nI degraded PyMySQL from (0.7.2) to (0.6.6). It works for me.\nMy peewee version is 2.8.0\n", "I was having all sorts of problems like this with PyMySQL (0.7.2 and 0.6.6). I switched to MySQLdb and everything is good.\n" ]
2016-02-26T16:07:54
2016-06-19T11:08:52
2016-02-29T14:33:08
CONTRIBUTOR
null
Came across this problem when running a full test suite using `pymysql` with `Python 2.7`. If you attempt to pass in a binary to `BlobField`, it results in the following error upon execution. ``` build/bdist.linux-x86_64/egg/peewee.py:4494: in create ??? build/bdist.linux-x86_64/egg/peewee.py:4680: in save ??? build/bdist.linux-x86_64/egg/peewee.py:3213: in execute ??? build/bdist.linux-x86_64/egg/peewee.py:2628: in _execute ??? build/bdist.linux-x86_64/egg/peewee.py:3454: in execute_sql ??? .eggs/PyMySQL-0.7.2-py2.7.egg/pymysql/cursors.py:156: in execute query = self.mogrify(query, args) .eggs/PyMySQL-0.7.2-py2.7.egg/pymysql/cursors.py:135: in mogrify query = query % self._escape_args(args, conn) .eggs/PyMySQL-0.7.2-py2.7.egg/pymysql/cursors.py:110: in _escape_args return tuple(conn.escape(arg) for arg in args) .eggs/PyMySQL-0.7.2-py2.7.egg/pymysql/cursors.py:110: in <genexpr> return tuple(conn.escape(arg) for arg in args) .eggs/PyMySQL-0.7.2-py2.7.egg/pymysql/connections.py:781: in escape return escape_item(obj, self.charset, mapping=mapping) .eggs/PyMySQL-0.7.2-py2.7.egg/pymysql/converters.py:26: in escape_item val = encoder(val, mapping) .eggs/PyMySQL-0.7.2-py2.7.egg/pymysql/converters.py:109: in escape_unicode return u"'%s'" % _escape_unicode(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ value = <read-only buffer for 0x7f4027d59880, size -1, offset 0 at 0x7f4027d653f0>, mapping = None def _escape_unicode(value, mapping=None): """escapes *value* without adding quote. Value should be unicode """ > return value.translate(_escape_table) E AttributeError: 'buffer' object has no attribute 'translate' mapping = None value = <read-only buffer for 0x7f4027d59880, size -1, offset 0 at 0x7f4027d653f0> .eggs/PyMySQL-0.7.2-py2.7.egg/pymysql/converters.py:72: AttributeError >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> entering PDB >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> > /vagrant/peewee-extras/.eggs/PyMySQL-0.7.2-py2.7.egg/pymysql/converters.py(72)_escape_unicode() -> return value.translate(_escape_table) ``` Code to reproduce the problem; ``` class TestModel(Model): value = BlobField() v = binascii.unhexlify('0a0a0a') OrderedUUIDModel.create(value=str(v)) ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/871/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/871/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/870
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/870/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/870/comments
https://api.github.com/repos/coleifer/peewee/issues/870/events
https://github.com/coleifer/peewee/issues/870
136,512,019
MDU6SXNzdWUxMzY1MTIwMTk=
870
Document `playhouse` model paths
{ "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
[ "Awesome, thanks!\n" ]
2016-02-25T21:05:30
2016-02-27T23:16:19
2016-02-26T18:05:24
NONE
null
I was working through the peewee documentation on [PickledField](http://docs.peewee-orm.com/en/latest/peewee/playhouse.html#PickledField). However, I could find nowhere in the documentation where to import this from. I tried: - the documentation page, near as I can tell, doesn't list this directly - looking at the page documentation source, but there's no `current module` directive - `PickledField` is listed in neither `dir(peewee)` or `dir(playhouse)` This seems to be the case for all the classes listed under Playhouse. I would recommend listing the import path somewhere in the documentation. Maybe just under each class: > available at `playhouse.fields.PickledField`
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/870/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/870/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/869
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/869/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/869/comments
https://api.github.com/repos/coleifer/peewee/issues/869/events
https://github.com/coleifer/peewee/pull/869
136,276,149
MDExOlB1bGxSZXF1ZXN0NjA2MjMyMTY=
869
Enable syntax highlight in Python snippet codes
{ "login": "mazulo", "id": 1661112, "node_id": "MDQ6VXNlcjE2NjExMTI=", "avatar_url": "https://avatars.githubusercontent.com/u/1661112?v=4", "gravatar_id": "", "url": "https://api.github.com/users/mazulo", "html_url": "https://github.com/mazulo", "followers_url": "https://api.github.com/users/mazulo/followers", "following_url": "https://api.github.com/users/mazulo/following{/other_user}", "gists_url": "https://api.github.com/users/mazulo/gists{/gist_id}", "starred_url": "https://api.github.com/users/mazulo/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/mazulo/subscriptions", "organizations_url": "https://api.github.com/users/mazulo/orgs", "repos_url": "https://api.github.com/users/mazulo/repos", "events_url": "https://api.github.com/users/mazulo/events{/privacy}", "received_events_url": "https://api.github.com/users/mazulo/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Thank you!\nOn Feb 24, 2016 10:19 PM, \"Patrick Mazulo\" [email protected] wrote:\n\n> ## Improve the read of the code\n> \n> You can view, comment on, or merge this pull request online at:\n> \n> https://github.com/coleifer/peewee/pull/869\n> Commit Summary\n> - Enable syntax highlight\n> - Merge pull request #1 from mazulo/mazulo-patch-1\n> \n> File Changes\n> - _M_ README.rst\n> https://github.com/coleifer/peewee/pull/869/files#diff-0 (16)\n> \n> Patch Links:\n> - https://github.com/coleifer/peewee/pull/869.patch\n> - https://github.com/coleifer/peewee/pull/869.diff\n> \n> —\n> Reply to this email directly or view it on GitHub\n> https://github.com/coleifer/peewee/pull/869.\n" ]
2016-02-25T04:19:18
2016-02-25T14:06:25
2016-02-25T14:05:50
CONTRIBUTOR
null
Improve the read of the code
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/869/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/869/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/869", "html_url": "https://github.com/coleifer/peewee/pull/869", "diff_url": "https://github.com/coleifer/peewee/pull/869.diff", "patch_url": "https://github.com/coleifer/peewee/pull/869.patch", "merged_at": "2016-02-25T14:05:50" }
https://api.github.com/repos/coleifer/peewee/issues/868
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/868/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/868/comments
https://api.github.com/repos/coleifer/peewee/issues/868/events
https://github.com/coleifer/peewee/issues/868
136,243,207
MDU6SXNzdWUxMzYyNDMyMDc=
868
Spatialite Extension "Function not found"
{ "login": "disarticulate", "id": 17464125, "node_id": "MDQ6VXNlcjE3NDY0MTI1", "avatar_url": "https://avatars.githubusercontent.com/u/17464125?v=4", "gravatar_id": "", "url": "https://api.github.com/users/disarticulate", "html_url": "https://github.com/disarticulate", "followers_url": "https://api.github.com/users/disarticulate/followers", "following_url": "https://api.github.com/users/disarticulate/following{/other_user}", "gists_url": "https://api.github.com/users/disarticulate/gists{/gist_id}", "starred_url": "https://api.github.com/users/disarticulate/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/disarticulate/subscriptions", "organizations_url": "https://api.github.com/users/disarticulate/orgs", "repos_url": "https://api.github.com/users/disarticulate/repos", "events_url": "https://api.github.com/users/disarticulate/events{/privacy}", "received_events_url": "https://api.github.com/users/disarticulate/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "You need to load the extension every time you connect... Could that be the issue?\n", "```\ndatabase.connect()\ndatabase.load_extension('mod_spatialite')\nsql = 'SELECT sqlite_version(), spatialite_version()'\nprint(database.execute_sql(sql).fetchall())\nLocations.insert(geometry=geometryFromWKT('POINT(4 9 3 `2)')).execute()\n```\n\n```\n>>[('3.8.11', '4.3.0a')]\n> >---------------------------------------------------------------------------\n> OperationalError Traceback (most recent call last)\n> C:\\Users\\Tsai\\Anaconda3\\envs\\flask\\lib\\site-packages\\peewee.py in execute_sql(self, sql, params, require_commit)\n> 3453 try:\n> -> 3454 cursor.execute(sql, params or ())\n> 3455 except Exception:\n> \n> OperationalError: no such function: ST_GeomFromText\n> \n> During handling of the above exception, another exception occurred:\n> \n> OperationalError Traceback (most recent call last)\n> <ipython-input-13-03efd5976860> in <module>()\n> 1 database.connect()\n> 2 database.load_extension('mod_spatialite')\n> ----> 3 Locations.insert(geometry=geometryFromWKT('POINT(4 9 3 2)')).execute()\n> \n> C:\\Users\\Tsai\\Anaconda3\\envs\\flask\\lib\\site-packages\\peewee.py in execute(self)\n> 3211 return self._qr\n> 3212 else:\n> -> 3213 cursor = self._execute()\n> 3214 if not self._is_multi_row_insert:\n> 3215 if self.database.insert_returning:\n> \n> C:\\Users\\Tsai\\Anaconda3\\envs\\flask\\lib\\site-packages\\peewee.py in _execute(self)\n> 2626 def _execute(self):\n> 2627 sql, params = self.sql()\n> -> 2628 return self.database.execute_sql(sql, params, self.require_commit)\n> 2629 \n> 2630 def execute(self):\n> \n> C:\\Users\\Tsai\\Anaconda3\\envs\\flask\\lib\\site-packages\\peewee.py in execute_sql(self, sql, params, require_commit)\n> 3459 else:\n> 3460 if require_commit and self.get_autocommit():\n> -> 3461 self.commit()\n> 3462 return cursor\n> 3463 \n> \n> C:\\Users\\Tsai\\Anaconda3\\envs\\flask\\lib\\site-packages\\peewee.py in __exit__(self, exc_type, exc_value, traceback)\n> 3283 else:\n> 3284 exc_args = exc_value.args\n> -> 3285 reraise(new_type, new_type(*exc_args), traceback)\n> 3286 \n> 3287 class _BaseConnectionLocal(object):\n> \n> C:\\Users\\Tsai\\Anaconda3\\envs\\flask\\lib\\site-packages\\peewee.py in reraise(tp, value, tb)\n> 125 def reraise(tp, value, tb=None):\n> 126 if value.__traceback__ is not tb:\n> --> 127 raise value.with_traceback(tb)\n> 128 raise value\n> 129 elif PY2:\n> \n> C:\\Users\\Tsai\\Anaconda3\\envs\\flask\\lib\\site-packages\\peewee.py in execute_sql(self, sql, params, require_commit)\n> 3452 cursor = self.get_cursor()\n> 3453 try:\n> -> 3454 cursor.execute(sql, params or ())\n> 3455 except Exception:\n> 3456 if self.get_autocommit() and self.autorollback:\n> \n> OperationalError: no such function: ST_GeomFromText\n```\n", "I'm not at all sure what's going on there. Possibly your SQLite driver is not built with support for Spatialite, or is linked against a different SQLite library? At any rate, I don't believe this is a problem with peewee, which I use with extension modules regularly.\n", "Thanks for the help.\n\nOn Fri, Feb 26, 2016 at 12:07 PM, Charles Leifer [email protected]\nwrote:\n\n> Closed #868 https://github.com/coleifer/peewee/issues/868.\n> \n> —\n> Reply to this email directly or view it on GitHub\n> https://github.com/coleifer/peewee/issues/868#event-567934835.\n\n## \n\ndis·ar·tic·u·late Audio pronunciation of \"disarticulate\" ( P )\nPronunciation Key (dsär-tky-lt)\nv. dis·ar·tic·u·lat·ed, dis·ar·tic·u·lat·ing, dis·ar·tic·u·lates\nv. tr.\n\n```\nTo separate at the joints; disjoint.\n```\n\nv. intr.\n\n```\nTo become disjointed.\n```\n" ]
2016-02-25T01:19:38
2016-02-26T18:22:55
2016-02-26T18:07:43
NONE
null
following this issue resolution: https://github.com/coleifer/peewee/issues/292 I'm just plain confused, if the version pops up correctly, this should mean the extension loaded: I'm getting: > OperationalError: no such function: ST_GeomFromText > ([(http://www.gaia-gis.it/gaia-sins/spatialite-sql-4.3.0.html)](http://www.gaia-gis.it/gaia-sins/spatialite-sql-4.3.0.html)) ``` from peewee import * from playhouse.sqlite_ext import SqliteExtDatabase ``` ``` def createDatabase(path): database = SqliteExtDatabase(path) database.connect() database.load_extension('mod_spatialite') database.create_tables([People, Entities, Affiliations, Projects, Locations, Pictures, Documents, Comments, Notes, LogBook], safe=True) sql = 'SELECT sqlite_version(), spatialite_version(),' print(database.execute_sql(sql).fetchall()) sql = 'SELECT InitSpatialMetadata()' database.execute_sql(sql) database.register_fields({'geometry':'geometry'}) return database ``` print for version returns: > [('3.8.11', '4.3.0a')] Which is Spatialite 4.3.0a function to update: ``` def geometryFromWKT(wellknowntext): return fn.ST_GeomFromText(wellknowntext) ``` Object: ``` class Locations(BaseModel): key = PrimaryKeyField() daterecord = DateField(null=False, help_text="Date Record", default=datetime.now().date()) timerecord = TimeField(null=True, help_text="Time Record") comments = TextField(null = True, help_text="Comment on the Geometry/Locations details") geometry = GeometryField() geometrytype = TextField(null = True, help_text="Geometrytype from WKT details") geometrytable = TextField(null = True, help_text="Name of Database Table from Geometry Import") isdesignfile = BooleanField(null = False, help_text='Is the location part of the project design or not (asbuilt, observation)') ``` field: ``` class GeometryField(Field): db_field = 'geometry' ``` Insert method.: `Locations.insert(geometry=geometryFromWKT('POINT(4` 9 3 2)')).execute()
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/868/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/868/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/867
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/867/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/867/comments
https://api.github.com/repos/coleifer/peewee/issues/867/events
https://github.com/coleifer/peewee/issues/867
135,405,932
MDU6SXNzdWUxMzU0MDU5MzI=
867
http://www.peewee-orm.com/ gives "Not found."
{ "login": "kramer65", "id": 596581, "node_id": "MDQ6VXNlcjU5NjU4MQ==", "avatar_url": "https://avatars.githubusercontent.com/u/596581?v=4", "gravatar_id": "", "url": "https://api.github.com/users/kramer65", "html_url": "https://github.com/kramer65", "followers_url": "https://api.github.com/users/kramer65/followers", "following_url": "https://api.github.com/users/kramer65/following{/other_user}", "gists_url": "https://api.github.com/users/kramer65/gists{/gist_id}", "starred_url": "https://api.github.com/users/kramer65/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/kramer65/subscriptions", "organizations_url": "https://api.github.com/users/kramer65/orgs", "repos_url": "https://api.github.com/users/kramer65/repos", "events_url": "https://api.github.com/users/kramer65/events{/privacy}", "received_events_url": "https://api.github.com/users/kramer65/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Actually it used to do that so I was surprised by your note. I went in and looked at the nginx config and realized I hadn't updated it for when I removed Varnish from my site. The redirects should be working now. Thank you!\n" ]
2016-02-22T12:41:27
2016-02-22T15:06:13
2016-02-22T15:06:13
NONE
null
Although I know the docs can be found at http://docs.peewee-orm.com/ , it looks pretty crappy if the root of a website gives an Error. Maybe it would be good to redirect http://www.peewee-orm.com/ to http://docs.peewee-orm.com/ Cheers!
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/867/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/867/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/866
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/866/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/866/comments
https://api.github.com/repos/coleifer/peewee/issues/866/events
https://github.com/coleifer/peewee/pull/866
135,276,884
MDExOlB1bGxSZXF1ZXN0NjAxMTAyMDc=
866
Added SmallIntegerField to __all__
{ "login": "bcattle", "id": 620058, "node_id": "MDQ6VXNlcjYyMDA1OA==", "avatar_url": "https://avatars.githubusercontent.com/u/620058?v=4", "gravatar_id": "", "url": "https://api.github.com/users/bcattle", "html_url": "https://github.com/bcattle", "followers_url": "https://api.github.com/users/bcattle/followers", "following_url": "https://api.github.com/users/bcattle/following{/other_user}", "gists_url": "https://api.github.com/users/bcattle/gists{/gist_id}", "starred_url": "https://api.github.com/users/bcattle/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/bcattle/subscriptions", "organizations_url": "https://api.github.com/users/bcattle/orgs", "repos_url": "https://api.github.com/users/bcattle/repos", "events_url": "https://api.github.com/users/bcattle/events{/privacy}", "received_events_url": "https://api.github.com/users/bcattle/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[]
2016-02-21T23:45:01
2016-02-22T03:39:43
2016-02-22T03:39:43
CONTRIBUTOR
null
`SmallIntegerField` wasn't listed in the peewee module `__all__` list.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/866/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/866/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/866", "html_url": "https://github.com/coleifer/peewee/pull/866", "diff_url": "https://github.com/coleifer/peewee/pull/866.diff", "patch_url": "https://github.com/coleifer/peewee/pull/866.patch", "merged_at": "2016-02-22T03:39:43" }
https://api.github.com/repos/coleifer/peewee/issues/865
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/865/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/865/comments
https://api.github.com/repos/coleifer/peewee/issues/865/events
https://github.com/coleifer/peewee/issues/865
135,102,379
MDU6SXNzdWUxMzUxMDIzNzk=
865
Documentation, code example for webapp2
{ "login": "onel", "id": 1862405, "node_id": "MDQ6VXNlcjE4NjI0MDU=", "avatar_url": "https://avatars.githubusercontent.com/u/1862405?v=4", "gravatar_id": "", "url": "https://api.github.com/users/onel", "html_url": "https://github.com/onel", "followers_url": "https://api.github.com/users/onel/followers", "following_url": "https://api.github.com/users/onel/following{/other_user}", "gists_url": "https://api.github.com/users/onel/gists{/gist_id}", "starred_url": "https://api.github.com/users/onel/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/onel/subscriptions", "organizations_url": "https://api.github.com/users/onel/orgs", "repos_url": "https://api.github.com/users/onel/repos", "events_url": "https://api.github.com/users/onel/events{/privacy}", "received_events_url": "https://api.github.com/users/onel/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Going to pass as this is a pretty obscure framework.\n", "We use this framework (webapp2) with peewee. We never call connect() or close(). Is that bad?", "@savraj -- Probably... I don't know webapp2, but my guess is that you aren't getting the concurrency you think you might be if you're running in certain types of environments.\r\n\r\nIf you're using a webapp, my opinion is that you should always open a conn upon receiving a connection and close it afterwards. You *can* use a connection pool if you get a lot of traffic, but that's how I would do things." ]
2016-02-20T17:11:14
2018-03-07T02:04:22
2016-02-20T17:18:40
NONE
null
I know webapp2 is mainly used with app engine, but I started using it ouside of GAE and with peewee. You can add the documentation for the db opening, closing on each request ``` python class BaseHandler(webapp2.RequestHandler): def dispatch(self): db.connect() try: # Dispatch the request. webapp2.RequestHandler.dispatch(self) finally: if not db.is_closed(): db.close() ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/865/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/865/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/864
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/864/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/864/comments
https://api.github.com/repos/coleifer/peewee/issues/864/events
https://github.com/coleifer/peewee/issues/864
135,029,767
MDU6SXNzdWUxMzUwMjk3Njc=
864
RHEL python 3.4 Unable to create SQLITE db
{ "login": "sripathivenky", "id": 2147479, "node_id": "MDQ6VXNlcjIxNDc0Nzk=", "avatar_url": "https://avatars.githubusercontent.com/u/2147479?v=4", "gravatar_id": "", "url": "https://api.github.com/users/sripathivenky", "html_url": "https://github.com/sripathivenky", "followers_url": "https://api.github.com/users/sripathivenky/followers", "following_url": "https://api.github.com/users/sripathivenky/following{/other_user}", "gists_url": "https://api.github.com/users/sripathivenky/gists{/gist_id}", "starred_url": "https://api.github.com/users/sripathivenky/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/sripathivenky/subscriptions", "organizations_url": "https://api.github.com/users/sripathivenky/orgs", "repos_url": "https://api.github.com/users/sripathivenky/repos", "events_url": "https://api.github.com/users/sripathivenky/events{/privacy}", "received_events_url": "https://api.github.com/users/sripathivenky/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "No idea, but somehow your install isn't finding a python sqlite driver.\n" ]
2016-02-20T03:57:59
2016-02-20T03:59:12
2016-02-20T03:59:12
NONE
null
Keep running into > Traceback (most recent call last): > File "db_test.py", line 2, in <module> > from playhouse.sqlite_ext import SqliteExtDatabase > File "/home/srujan/pyats/pyats/lib/python3.4/site-packages/playhouse/sqlite_ext.py", line 74, in <module> > FTS_VER = sqlite3.sqlite_version_info[:3] >= (3, 7, 4) and 'FTS4' or 'FTS3' > AttributeError: 'NoneType' object has no attribute 'sqlite_version_info' Upgraded the sqlite3 version to : 3.11.0 2016-02-15 17:29:24 3d862f207e3adc00f78066799ac5a8c282430a5f from peewee import * from playhouse.sqlite_ext import SqliteExtDatabase import datetime db = SqliteExtDatabase('my_database.db') class BaseModel(Model): class Meta: database = db class User(BaseModel): username = CharField(unique=True) class Tweet(BaseModel): user = ForeignKeyField(User, related_name='tweets') message = TextField() created_date = DateTimeField(default=datetime.datetime.now) is_published = BooleanField(default=True)
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/864/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/864/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/863
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/863/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/863/comments
https://api.github.com/repos/coleifer/peewee/issues/863/events
https://github.com/coleifer/peewee/issues/863
134,969,950
MDU6SXNzdWUxMzQ5Njk5NTA=
863
Can't create index on TextField. Database is MySQL
{ "login": "tgrant59", "id": 4661702, "node_id": "MDQ6VXNlcjQ2NjE3MDI=", "avatar_url": "https://avatars.githubusercontent.com/u/4661702?v=4", "gravatar_id": "", "url": "https://api.github.com/users/tgrant59", "html_url": "https://github.com/tgrant59", "followers_url": "https://api.github.com/users/tgrant59/followers", "following_url": "https://api.github.com/users/tgrant59/following{/other_user}", "gists_url": "https://api.github.com/users/tgrant59/gists{/gist_id}", "starred_url": "https://api.github.com/users/tgrant59/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/tgrant59/subscriptions", "organizations_url": "https://api.github.com/users/tgrant59/orgs", "repos_url": "https://api.github.com/users/tgrant59/repos", "events_url": "https://api.github.com/users/tgrant59/events{/privacy}", "received_events_url": "https://api.github.com/users/tgrant59/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Yeah, that's a limitation of MySQL -- you need to specify a length to index when you have a `TextField`.\n" ]
2016-02-19T20:46:57
2016-02-20T03:36:14
2016-02-20T03:36:14
NONE
null
When I run create_table() on a model with a TextField(index=True) column, it fails with this error: ``` peewee.OperationalError: (1170, "BLOB/TEXT column 'keywords' used in key specification without a key length") ``` The table is created successfully, but the index is not. Here's a simple example which reproduces the error using my setup: ``` python import peewee from playhouse.pool import PooledMySQLDatabase class TestModel(peewee.Model): keywords = p.TextField(index=True) class Meta: database = PooledMySQLDatabase("testdb", user="user", passwd="password") TestModel.create_table() ``` ``` peewee==2.7.4 MySQL-python==1.2.5 mysql Ver 14.14 Distrib 5.7.9, for osx10.10 (x86_64) using EditLine wrapper ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/863/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/863/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/862
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/862/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/862/comments
https://api.github.com/repos/coleifer/peewee/issues/862/events
https://github.com/coleifer/peewee/pull/862
134,872,872
MDExOlB1bGxSZXF1ZXN0NTk5NTI4NjA=
862
Implement TRUNCATE TABLE ... as truncate_table()
{ "login": "dev-zero", "id": 11307, "node_id": "MDQ6VXNlcjExMzA3", "avatar_url": "https://avatars.githubusercontent.com/u/11307?v=4", "gravatar_id": "", "url": "https://api.github.com/users/dev-zero", "html_url": "https://github.com/dev-zero", "followers_url": "https://api.github.com/users/dev-zero/followers", "following_url": "https://api.github.com/users/dev-zero/following{/other_user}", "gists_url": "https://api.github.com/users/dev-zero/gists{/gist_id}", "starred_url": "https://api.github.com/users/dev-zero/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/dev-zero/subscriptions", "organizations_url": "https://api.github.com/users/dev-zero/orgs", "repos_url": "https://api.github.com/users/dev-zero/repos", "events_url": "https://api.github.com/users/dev-zero/events{/privacy}", "received_events_url": "https://api.github.com/users/dev-zero/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Looks nice, add a couple tests and I'll merge.\n" ]
2016-02-19T14:03:21
2016-02-20T03:51:08
2016-02-20T03:51:08
NONE
null
Implemented by MySQL and PostgreSQL (and SQL2008), only PostgreSQL supports `CASCADE`.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/862/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/862/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/862", "html_url": "https://github.com/coleifer/peewee/pull/862", "diff_url": "https://github.com/coleifer/peewee/pull/862.diff", "patch_url": "https://github.com/coleifer/peewee/pull/862.patch", "merged_at": null }
https://api.github.com/repos/coleifer/peewee/issues/861
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/861/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/861/comments
https://api.github.com/repos/coleifer/peewee/issues/861/events
https://github.com/coleifer/peewee/issues/861
134,680,260
MDU6SXNzdWUxMzQ2ODAyNjA=
861
2.8.0 breaks custom Field subclasses that don't check for None
{ "login": "josefdlange", "id": 1062835, "node_id": "MDQ6VXNlcjEwNjI4MzU=", "avatar_url": "https://avatars.githubusercontent.com/u/1062835?v=4", "gravatar_id": "", "url": "https://api.github.com/users/josefdlange", "html_url": "https://github.com/josefdlange", "followers_url": "https://api.github.com/users/josefdlange/followers", "following_url": "https://api.github.com/users/josefdlange/following{/other_user}", "gists_url": "https://api.github.com/users/josefdlange/gists{/gist_id}", "starred_url": "https://api.github.com/users/josefdlange/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/josefdlange/subscriptions", "organizations_url": "https://api.github.com/users/josefdlange/orgs", "repos_url": "https://api.github.com/users/josefdlange/repos", "events_url": "https://api.github.com/users/josefdlange/events{/privacy}", "received_events_url": "https://api.github.com/users/josefdlange/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "My best guess is that a DB value of `None` would, in prior versions, never get passed to the `Field` subclass's `python_value` method but instead short-circuit to just returning `None`.\n\nThis is kind of a breaking change that isn't noted in the `CHANGELOG` if it proves to be what I'm experiencing. Granted I should have `None`-checked anyway but Figured this is a good word of warning to anyone in the future.\n", "Might be related to #791 actually; perhaps my `python_value` method was bad all along and just never being called because of this bug! These fields are PKs of tables....\n", "I'm pretty sure it's been that way for a while. Not an issue, IMO.\n", "Fair enough. Moving from 2.7.4 --> 2.8.0 broke this for me, but so long as the solution is to fix my own f*cking code I can live with that :)\n" ]
2016-02-18T20:00:26
2016-02-19T02:34:03
2016-02-19T02:32:38
CONTRIBUTOR
null
This is a lot of conjecture (and I'm moving at a pace too quick to really reproduce and test this out), but I'm pretty sure 2.8.0 breaks a Field subclass defined like this: ``` class MyField(Field): def python_value(value): return some_thing_that_cant_take_none(value) ``` I had to change a `Field` subclass of mine to work like so: ``` class MyField(Field): def python_value(value): if value is None: return None return some_thing_that_cant_take_none(value) ``` Not a big deal to me in the long run, but if it's a field that is fundamental to a data model it's a rather obscure issue.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/861/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/861/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/860
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/860/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/860/comments
https://api.github.com/repos/coleifer/peewee/issues/860/events
https://github.com/coleifer/peewee/issues/860
134,530,846
MDU6SXNzdWUxMzQ1MzA4NDY=
860
Using << with an empty list creates an invalid SQL query
{ "login": "Prillan", "id": 1675190, "node_id": "MDQ6VXNlcjE2NzUxOTA=", "avatar_url": "https://avatars.githubusercontent.com/u/1675190?v=4", "gravatar_id": "", "url": "https://api.github.com/users/Prillan", "html_url": "https://github.com/Prillan", "followers_url": "https://api.github.com/users/Prillan/followers", "following_url": "https://api.github.com/users/Prillan/following{/other_user}", "gists_url": "https://api.github.com/users/Prillan/gists{/gist_id}", "starred_url": "https://api.github.com/users/Prillan/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/Prillan/subscriptions", "organizations_url": "https://api.github.com/users/Prillan/orgs", "repos_url": "https://api.github.com/users/Prillan/repos", "events_url": "https://api.github.com/users/Prillan/events{/privacy}", "received_events_url": "https://api.github.com/users/Prillan/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Rather than modify the SQL behind-the-scenes, you should check your list at run-time.\n", "I get that, I'm fine with checking if the list is empty. I'm just against creating an invalid query since it results in a syntax error. The error should be thrown before it gets to the database and not in it. To me this is like having a compiler generate invalid code, something that shouldn't be figured out when you try to run the code, but rather at compile time.\n" ]
2016-02-18T09:49:52
2016-02-18T16:24:23
2016-02-18T14:38:45
NONE
null
``` psycopg2.ProgrammingError: syntax error at or near ")" ``` I think either of the following solutions are acceptable: - Throw an error in peewee indicating that the list (iterator) is empty. - Transform `column << []` into `False` before compiling to SQL. Not handling this before sending it to the database causes all queries after it to fail (at least on our flask server) with error: ``` peewee.InternalError: current transaction is aborted, commands ignored until end of transaction block ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/860/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/860/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/859
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/859/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/859/comments
https://api.github.com/repos/coleifer/peewee/issues/859/events
https://github.com/coleifer/peewee/pull/859
134,461,955
MDExOlB1bGxSZXF1ZXN0NTk3NDE0NTg=
859
Get extra connection args from query string in db_url
{ "login": "RealSalmon", "id": 943086, "node_id": "MDQ6VXNlcjk0MzA4Ng==", "avatar_url": "https://avatars.githubusercontent.com/u/943086?v=4", "gravatar_id": "", "url": "https://api.github.com/users/RealSalmon", "html_url": "https://github.com/RealSalmon", "followers_url": "https://api.github.com/users/RealSalmon/followers", "following_url": "https://api.github.com/users/RealSalmon/following{/other_user}", "gists_url": "https://api.github.com/users/RealSalmon/gists{/gist_id}", "starred_url": "https://api.github.com/users/RealSalmon/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/RealSalmon/subscriptions", "organizations_url": "https://api.github.com/users/RealSalmon/orgs", "repos_url": "https://api.github.com/users/RealSalmon/repos", "events_url": "https://api.github.com/users/RealSalmon/events{/privacy}", "received_events_url": "https://api.github.com/users/RealSalmon/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Looks good, just one thing to change and I'll be happy to merge.\n", "Actually that dictionary comprehension breaks in Python 2.6 (forgot about that). I didn't notice it before because travis didn't pick up the PR initially.\n", "A few fixes were required for Python 2.6.\n" ]
2016-02-18T02:18:22
2016-02-18T16:12:37
2016-02-18T16:12:37
CONTRIBUTOR
null
### Changes - As discussed in #858, this adds support for supplying extra connection args in the query string when using playhouse.db_url
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/859/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/859/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/859", "html_url": "https://github.com/coleifer/peewee/pull/859", "diff_url": "https://github.com/coleifer/peewee/pull/859.diff", "patch_url": "https://github.com/coleifer/peewee/pull/859.patch", "merged_at": "2016-02-18T16:12:37" }
https://api.github.com/repos/coleifer/peewee/issues/858
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/858/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/858/comments
https://api.github.com/repos/coleifer/peewee/issues/858/events
https://github.com/coleifer/peewee/issues/858
134,399,177
MDU6SXNzdWUxMzQzOTkxNzc=
858
Add support for additional connect args as query string in db_url
{ "login": "RealSalmon", "id": 943086, "node_id": "MDQ6VXNlcjk0MzA4Ng==", "avatar_url": "https://avatars.githubusercontent.com/u/943086?v=4", "gravatar_id": "", "url": "https://api.github.com/users/RealSalmon", "html_url": "https://github.com/RealSalmon", "followers_url": "https://api.github.com/users/RealSalmon/followers", "following_url": "https://api.github.com/users/RealSalmon/following{/other_user}", "gists_url": "https://api.github.com/users/RealSalmon/gists{/gist_id}", "starred_url": "https://api.github.com/users/RealSalmon/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/RealSalmon/subscriptions", "organizations_url": "https://api.github.com/users/RealSalmon/orgs", "repos_url": "https://api.github.com/users/RealSalmon/repos", "events_url": "https://api.github.com/users/RealSalmon/events{/privacy}", "received_events_url": "https://api.github.com/users/RealSalmon/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Yes!\n", "Great, I'll start messing around with it this evening (real life permitting . . . ). \n", "That's cool but how could we set False (eg. register_hstore) via url? Should parse the query string with `keep_blank_values=True`, right?\n" ]
2016-02-17T21:05:04
2016-05-24T13:43:39
2016-02-20T03:36:29
CONTRIBUTOR
null
I'm happy to take a stab at this, but I thought it best to first propose it prior to spending any time . . . When using playhouse.db_url for connections, it is not currently possible to include additional connect args directly in the connection string. These must instead be supplied as separate keyword args. ``` python connect('mysql+pool://user:passwd@ip:port/my_db', max_connections=20, stale_timeout=300) ``` It would be nice to get those extra connection arguments directly from the connection string itself ``` python # DATABASE_URL has mysql+pool://user:passwd@ip:port/my_db?max_connections=20&stale_timeout=300 connect(os.environ['DATABASE_URL']) ``` Thoughts?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/858/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/858/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/857
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/857/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/857/comments
https://api.github.com/repos/coleifer/peewee/issues/857/events
https://github.com/coleifer/peewee/issues/857
134,389,581
MDU6SXNzdWUxMzQzODk1ODE=
857
deferred pool
{ "login": "coleifer", "id": 119974, "node_id": "MDQ6VXNlcjExOTk3NA==", "avatar_url": "https://avatars.githubusercontent.com/u/119974?v=4", "gravatar_id": "", "url": "https://api.github.com/users/coleifer", "html_url": "https://github.com/coleifer", "followers_url": "https://api.github.com/users/coleifer/followers", "following_url": "https://api.github.com/users/coleifer/following{/other_user}", "gists_url": "https://api.github.com/users/coleifer/gists{/gist_id}", "starred_url": "https://api.github.com/users/coleifer/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/coleifer/subscriptions", "organizations_url": "https://api.github.com/users/coleifer/orgs", "repos_url": "https://api.github.com/users/coleifer/repos", "events_url": "https://api.github.com/users/coleifer/events{/privacy}", "received_events_url": "https://api.github.com/users/coleifer/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "dc258ae727620c01d300c67ab58a73c9d1a15b7e\n" ]
2016-02-17T20:22:00
2016-02-20T03:40:50
2016-02-20T03:40:42
OWNER
null
I have a question regarding run-time database configuration as described here: http://docs.peewee-orm.com/en/latest/peewee/database.html#run-time-database-configuration Is this technique expected to work with the connection pooling extensions in playhouse.pool? e.g. . . . db = PooledMySQLDatabase(None) I end up getting a TypeError exception (TypeError: **init**() got an unexpected keyword argument 'stale_timeout') when I call init() because of the pooling-specific arguments (max_connection, stale_timeout).
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/857/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/857/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/856
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/856/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/856/comments
https://api.github.com/repos/coleifer/peewee/issues/856/events
https://github.com/coleifer/peewee/issues/856
134,110,986
MDU6SXNzdWUxMzQxMTA5ODY=
856
Peewee calls __init__ on model unexpectedly
{ "login": "jrs65", "id": 695206, "node_id": "MDQ6VXNlcjY5NTIwNg==", "avatar_url": "https://avatars.githubusercontent.com/u/695206?v=4", "gravatar_id": "", "url": "https://api.github.com/users/jrs65", "html_url": "https://github.com/jrs65", "followers_url": "https://api.github.com/users/jrs65/followers", "following_url": "https://api.github.com/users/jrs65/following{/other_user}", "gists_url": "https://api.github.com/users/jrs65/gists{/gist_id}", "starred_url": "https://api.github.com/users/jrs65/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/jrs65/subscriptions", "organizations_url": "https://api.github.com/users/jrs65/orgs", "repos_url": "https://api.github.com/users/jrs65/repos", "events_url": "https://api.github.com/users/jrs65/events{/privacy}", "received_events_url": "https://api.github.com/users/jrs65/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Try modifying your `__init__` to:\n\n```\ndef __init__(self, a=2, **kwargs):\n pw.Model.__init__(self, a=a, **kwargs)\n```\n", "@lez is correct. Models that override `__init__()` should accept arbitrary kwargs and pass them to the parent constructor. Really, you should not be overriding `__init__()` in the first place though.\n", "Thanks. I guess my confusion came from the fact this used to work fine on earlier versions.\n\nMight be worth a mention in the documentation about not overriding `__init__` or how to do it if you must. It's quite a natural thing to want to do, and it breaks in places that are a little unexpected if you do it incorrectly. If I get time in the next few days, I'll do it myself and send in a PR. \n", "Same with me. I overrode __init__() and it used to work, but I believe I upgraded to a newer version of peewee and it now spits out the following error:\r\n\r\nTypeError: __init__() got an unexpected keyword argument 'database_column_name'", "@coleifer so what is the right way to init the data fields of peewee.Model descendant class?", "> so what is the right way to init the data fields of peewee.Model descendant class\r\n\r\nA `Model` class represents a row of data, which it is initialized with. What you mean by \"data fields\" is unclear to me. You can always override the init method, but with the caveat that it your implementation must accept arbitrary keyword arguments and also call the parent constructor.", "thanks @coleifer!\r\n\r\nsuppose I have a _Car_ class that inherits from _peewee.Model_. If I want to initialise an object of the _Car_ class with individual values, I can just use the constructor:\r\n\r\n```\r\ncar_object = Car(seats=6, cylinders=2)\r\n```\r\n\r\nSo far, so good! \r\n\r\nBut now suppose I want to initialise the _Car_ object, starting from another object, say some _CarConfig_ object and the initialisation requires some logic, more than just assigning fields 1-to-1.\r\n\r\nWithout peewee, I would simply define my \\_\\_init\\_\\_() method and put all the initialisation logic there\r\n\r\n```\r\nclass Car:\r\n\r\n def __init__(self, car_config_object):\r\n ... some complex initialisation logic here that uses the car_config_object ...\r\n```\r\n\r\nbut I can't define the \\_\\_init\\_\\_() method in _peewee.Model_ descendant classes anymore. \r\nSo where do I put all that complex initialisation logic?\r\n", "You can still put it in `__init__()` with the caveat that `__init__()` is going to be called not just when instantiating objects yourself, but also every time a `Car` instance is read from a database cursor. I think you probably could make a classmethod on your `Car` object and use that as a factory for complex logic?", "good idea - I think the factory method is the way to go!", "Could someone share an example of how would that factory method look like ?", "@mauriciogracia \r\n\r\n```\r\nclass Tweet:\r\n @classmethod\r\n def new(cls, *args, **kwargs):\r\n tweet = cls()\r\n # Do complicated logic\r\n return tweet\r\n```\r\n\r\nThis is just a way to avoid overriding `__init__`.", "Since `__new__` does not trigger `__init__` in Python, would there be anything wrong with implicitly using `__new__` instead of explicitly using `Tweet.new` ?", "I would not advise it unless you're quite familiar with all the differences between `__new__` and `__init__` (which I myself am not quite sure of). If you need a specialized constructor, my advice is to just write an explicit `@classmethod` **or** you can just make very cautious modifications to `__init__`, e.g.\r\n\r\n```python\r\nclass User(Model):\r\n username = TextField()\r\n def __init__(self, *args, **kwargs):\r\n super(User, self).__init__(*args, **kwargs) # Ensure parent init is called correctly.\r\n # do complicated stuff here.\r\n```\r\n\r\nBut my advice is to probably stick to a classmethod constructor if your logic is particularly complex." ]
2016-02-16T22:10:12
2022-04-28T00:02:06
2016-02-17T18:18:32
NONE
null
We've run into some trouble when upgrading to peewee 2.8.0, when we have a custom `__init__` defined on our models. This behaviour worked fine when on earlier versions (2.7.3 is the other version I tested). ``` python import peewee as pw db = pw.SqliteDatabase(':memory:') class TestTable1(pw.Model): a = pw.IntegerField() b = pw.IntegerField(default=2) class Meta: database = db class TestTable2(pw.Model): def __init__(self, a=2): pw.Model.__init__(self, a=a) a = pw.IntegerField() b = pw.IntegerField(default=2) class Meta: database = db db.connect() db.create_tables([TestTable1, TestTable2]) # This works fine TestTable1.create(a=2) t1 = TestTable1.select().get() # This fails TestTable2.create(a=2) t2 = TestTable2.select().get() # Failure with: TypeError: __init__() got an unexpected keyword argument 'b' ``` In the code above, the failure occurs in the final select, it seems that when the model instance is created, the code in `playhouse._speedups._ModelQueryResultWrapper.process_row` uses `__init__` to create an instance of the row with the full results of the query passed as kwargs (i.e. a=2, b=2). However, the `TestTable2.__init__` does not support `b` as a keyword argument. It's not clear from the documentation how well I should expect custom `__init__` methods to work. However, I would imagine that this could be fixed by making `playhouse._speedups._ModelQueryResultWrapper.process_row` explicitly call `pw.Model.__init__` on an instance created via `__new__`.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/856/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/856/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/855
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/855/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/855/comments
https://api.github.com/repos/coleifer/peewee/issues/855/events
https://github.com/coleifer/peewee/pull/855
134,089,097
MDExOlB1bGxSZXF1ZXN0NTk1NDk0NTg=
855
pyramid integration docs updated
{ "login": "lez", "id": 203039, "node_id": "MDQ6VXNlcjIwMzAzOQ==", "avatar_url": "https://avatars.githubusercontent.com/u/203039?v=4", "gravatar_id": "", "url": "https://api.github.com/users/lez", "html_url": "https://github.com/lez", "followers_url": "https://api.github.com/users/lez/followers", "following_url": "https://api.github.com/users/lez/following{/other_user}", "gists_url": "https://api.github.com/users/lez/gists{/gist_id}", "starred_url": "https://api.github.com/users/lez/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/lez/subscriptions", "organizations_url": "https://api.github.com/users/lez/orgs", "repos_url": "https://api.github.com/users/lez/repos", "events_url": "https://api.github.com/users/lez/events{/privacy}", "received_events_url": "https://api.github.com/users/lez/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[]
2016-02-16T20:30:29
2016-02-17T00:25:49
2016-02-17T00:25:49
NONE
null
pyramid_peewee had been removed because - it's overly complicated - uses monkeypatching instead of well documented pyramid hooks - does more than just integration - overrides database exception types
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/855/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/855/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/855", "html_url": "https://github.com/coleifer/peewee/pull/855", "diff_url": "https://github.com/coleifer/peewee/pull/855.diff", "patch_url": "https://github.com/coleifer/peewee/pull/855.patch", "merged_at": "2016-02-17T00:25:49" }
https://api.github.com/repos/coleifer/peewee/issues/854
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/854/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/854/comments
https://api.github.com/repos/coleifer/peewee/issues/854/events
https://github.com/coleifer/peewee/issues/854
133,808,531
MDU6SXNzdWUxMzM4MDg1MzE=
854
Possibility to see what changes with a save?
{ "login": "kramer65", "id": 596581, "node_id": "MDQ6VXNlcjU5NjU4MQ==", "avatar_url": "https://avatars.githubusercontent.com/u/596581?v=4", "gravatar_id": "", "url": "https://api.github.com/users/kramer65", "html_url": "https://github.com/kramer65", "followers_url": "https://api.github.com/users/kramer65/followers", "following_url": "https://api.github.com/users/kramer65/following{/other_user}", "gists_url": "https://api.github.com/users/kramer65/gists{/gist_id}", "starred_url": "https://api.github.com/users/kramer65/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/kramer65/subscriptions", "organizations_url": "https://api.github.com/users/kramer65/orgs", "repos_url": "https://api.github.com/users/kramer65/repos", "events_url": "https://api.github.com/users/kramer65/events{/privacy}", "received_events_url": "https://api.github.com/users/kramer65/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Well, peewee knows that you set attributes so those are stored in the `dirty_fields` attribute. But there's no checking to see if it differed from the previous value. Any additional logic will have to live in your app itself.\n", "You can do `model.save(only=model.dirty_fields)`, if you just want to save those that were \"set\", but it doesn't track actual changes to the underyling value.\n", "Alright thanks. In that case I will need to build something myself.\n\nThanks!\n", "Why wouldn't peewee check whether values have actually changed? Speed?\r\n\r\nAnd would this be a good way to implement it?\r\n\r\n```python\r\nclass BaseModel(Model):\r\n class Meta:\r\n database = database\r\n only_save_dirty = True\r\n\r\n def __setattr__(self, name, value):\r\n if not hasattr(self, name) or getattr(self, name) is not value:\r\n return super().__setattr__(name, value)\r\n```" ]
2016-02-15T20:25:36
2016-12-14T21:54:24
2016-02-18T02:43:48
NONE
null
Let's say I've got a `User` model from which I start a new record as follows: ``` u = User() u.username = 'bob' u.location = 'home' u.save() ``` I now use the same user instance and write two values of which one is the same: ``` u.username = 'bob' # stays the same u.location = 'work' # changes u.save() ``` When saving the updated values, is there a way with Peewee to know which of the values changed (i.e.: `location`), without actually comparing them with the existing values? Ive got a model with about 50 fields to which I simply save the values of a json object. It would be so much easier if I could get the differences, instead of me needing to compare all those 50 values manually.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/854/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/854/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/853
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/853/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/853/comments
https://api.github.com/repos/coleifer/peewee/issues/853/events
https://github.com/coleifer/peewee/issues/853
133,219,416
MDU6SXNzdWUxMzMyMTk0MTY=
853
Support for conditional insert/update based on EXISTS/NOT EXISTS
{ "login": "dev-zero", "id": 11307, "node_id": "MDQ6VXNlcjExMzA3", "avatar_url": "https://avatars.githubusercontent.com/u/11307?v=4", "gravatar_id": "", "url": "https://api.github.com/users/dev-zero", "html_url": "https://github.com/dev-zero", "followers_url": "https://api.github.com/users/dev-zero/followers", "following_url": "https://api.github.com/users/dev-zero/following{/other_user}", "gists_url": "https://api.github.com/users/dev-zero/gists{/gist_id}", "starred_url": "https://api.github.com/users/dev-zero/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/dev-zero/subscriptions", "organizations_url": "https://api.github.com/users/dev-zero/orgs", "repos_url": "https://api.github.com/users/dev-zero/repos", "events_url": "https://api.github.com/users/dev-zero/events{/privacy}", "received_events_url": "https://api.github.com/users/dev-zero/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Here's an example of how to insert with a select query:\n\nhttp://docs.peewee-orm.com/en/latest/peewee/api.html#Model.insert_from\n\nFor postgres, you can use the on_conflict method:\n\nhttp://docs.peewee-orm.com/en/latest/peewee/api.html#InsertQuery.on_conflict\n\nI'll need to check if it works with postgres, as its only been tested on\nsqlite.\nOn Feb 12, 2016 5:39 AM, \"Tiziano Müller\" [email protected] wrote:\n\n> I couldn't figure out how to do an \"INSERT IF NOT EXISTS\" according to\n> http://stackoverflow.com/questions/15710162/conditional-insert-into-statement-in-postgres\n> in PostgreSQL. I am now using create_or_get instead, but it would be nice\n> if peewee would support the general \"exists/not exists\" in the when\n> function.\n> Likewise for the UPSERT function introduced in PostgreSQL-9.5\n> \n> —\n> Reply to this email directly or view it on GitHub\n> https://github.com/coleifer/peewee/issues/853.\n", "Ok, I tried the following:\n\n``` python\nmodels.TaskStatus.insert(name='done').on_conflict('IGNORE').execute()\n```\n\nwhich unfortunately generates a `INSERT OR IGNORE ...` which is not supported by PostgreSQL (I get a syntax error) instead of `sql INSERT ... ON CONFLICT` which is supposed to work with with PostgreSQL and MySQL.\n", "Hi, any word on `upsert` support for Postgres 9.5?\n", "I'm planning support for Postgres 9.5's new upsert functionality. Discussion has been consolidated into this ticket: #1307 . Please feel free to comment on that ticket with any thoughts or suggestions." ]
2016-02-12T11:39:32
2017-07-07T04:17:01
2017-07-07T04:17:01
NONE
null
I couldn't figure out how to do an "INSERT IF NOT EXISTS" according to http://stackoverflow.com/questions/15710162/conditional-insert-into-statement-in-postgres in PostgreSQL. I am now using `create_or_get` instead, but it would be nice if peewee would support the general "exists/not exists" in the `when` function. Likewise for the `UPSERT` function introduced in PostgreSQL-9.5
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/853/reactions", "total_count": 5, "+1": 5, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/853/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/852
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/852/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/852/comments
https://api.github.com/repos/coleifer/peewee/issues/852/events
https://github.com/coleifer/peewee/issues/852
133,200,861
MDU6SXNzdWUxMzMyMDA4NjE=
852
old SQLite3 has no sqlite3_compileoption_used function
{ "login": "gilchris", "id": 6995188, "node_id": "MDQ6VXNlcjY5OTUxODg=", "avatar_url": "https://avatars.githubusercontent.com/u/6995188?v=4", "gravatar_id": "", "url": "https://api.github.com/users/gilchris", "html_url": "https://github.com/gilchris", "followers_url": "https://api.github.com/users/gilchris/followers", "following_url": "https://api.github.com/users/gilchris/following{/other_user}", "gists_url": "https://api.github.com/users/gilchris/gists{/gist_id}", "starred_url": "https://api.github.com/users/gilchris/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/gilchris/subscriptions", "organizations_url": "https://api.github.com/users/gilchris/orgs", "repos_url": "https://api.github.com/users/gilchris/repos", "events_url": "https://api.github.com/users/gilchris/events{/privacy}", "received_events_url": "https://api.github.com/users/gilchris/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "That's one old ass sqlite.\n" ]
2016-02-12T10:09:49
2016-02-12T14:39:27
2016-02-12T14:39:19
NONE
null
If installed SQLite3 version is less than 2.6.23, [BerkeleyDatabase.check_libsqlite() function in berkeleydb.py](https://github.com/coleifer/peewee/blob/master/playhouse/berkeleydb.py#L102) raise AttributeError. sqlite3_compileoption_used function in SQlite is added on 2.6.23. [link](https://www.sqlite.org/releaselog/3_6_23.html)
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/852/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/852/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/851
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/851/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/851/comments
https://api.github.com/repos/coleifer/peewee/issues/851/events
https://github.com/coleifer/peewee/issues/851
133,109,489
MDU6SXNzdWUxMzMxMDk0ODk=
851
Postgresql Foreign key Migrations fail to rename columns
{ "login": "Hendler", "id": 144833, "node_id": "MDQ6VXNlcjE0NDgzMw==", "avatar_url": "https://avatars.githubusercontent.com/u/144833?v=4", "gravatar_id": "", "url": "https://api.github.com/users/Hendler", "html_url": "https://github.com/Hendler", "followers_url": "https://api.github.com/users/Hendler/followers", "following_url": "https://api.github.com/users/Hendler/following{/other_user}", "gists_url": "https://api.github.com/users/Hendler/gists{/gist_id}", "starred_url": "https://api.github.com/users/Hendler/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/Hendler/subscriptions", "organizations_url": "https://api.github.com/users/Hendler/orgs", "repos_url": "https://api.github.com/users/Hendler/repos", "events_url": "https://api.github.com/users/Hendler/events{/privacy}", "received_events_url": "https://api.github.com/users/Hendler/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Peewee uses the convention that foreign key columns end with \"_id\". No bug. Either change your migration to use user_id as the column, or in your field on the model specify db_column='user'\n", "Thanks I got confused by the create_table and column specific operations. \n" ]
2016-02-11T22:54:17
2016-02-22T22:33:52
2016-02-12T02:00:52
NONE
null
First, thanks for peewee. I've tried to include relevant bits for this example. Maybe I'm doing something wrong. ``` import basemodel from peewee import CharField, DateTimeField, BigIntegerField, BooleanField, IntegerField, ForeignKeyField, Proxy, TextField, PrimaryKeyField from playhouse.postgres_ext import BinaryJSONField, ArrayField from playhouse.migrate import PostgresqlMigrator from playhouse.migrate import migrate as mm mdb = basemodel.dbfactory() migrator = PostgresqlMigrator(mdb) def migration_wrapper(*args): with mdb.transaction(): mm(*args) migration_wrapper( migrator.add_column('blogpost', 'user', ForeignKeyField(User, related_name='posts', index=True, null=True, to_field=User.id)) ) ``` This creates a column called `user`. The model file also has this field, as "user". BUT using create_table would create a column named `user_id`. So, future inserts fail ``` post = BlogPost() post.user = User.get(id=user_id) post.save() # <- column not found ``` probably unrelated to #474 ?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/851/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/851/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/850
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/850/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/850/comments
https://api.github.com/repos/coleifer/peewee/issues/850/events
https://github.com/coleifer/peewee/issues/850
132,922,086
MDU6SXNzdWUxMzI5MjIwODY=
850
ALTER_COLUMN with MariaDB
{ "login": "ptbrowne", "id": 465582, "node_id": "MDQ6VXNlcjQ2NTU4Mg==", "avatar_url": "https://avatars.githubusercontent.com/u/465582?v=4", "gravatar_id": "", "url": "https://api.github.com/users/ptbrowne", "html_url": "https://github.com/ptbrowne", "followers_url": "https://api.github.com/users/ptbrowne/followers", "following_url": "https://api.github.com/users/ptbrowne/following{/other_user}", "gists_url": "https://api.github.com/users/ptbrowne/gists{/gist_id}", "starred_url": "https://api.github.com/users/ptbrowne/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/ptbrowne/subscriptions", "organizations_url": "https://api.github.com/users/ptbrowne/orgs", "repos_url": "https://api.github.com/users/ptbrowne/repos", "events_url": "https://api.github.com/users/ptbrowne/events{/privacy}", "received_events_url": "https://api.github.com/users/ptbrowne/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "That's odd, are you using the `MySQLMigrator`? The `add_not_null()` method appears to be using the \"MODIFY\" syntax.\n", "My bad... That was it, I was using PostgreSQLMigrator >< Thanks\n" ]
2016-02-11T09:08:32
2016-02-12T09:09:58
2016-02-12T09:08:29
NONE
null
Hi, I am using MariaDB (10.1.10 released on 2015-12.24) and peewee 2.8.0 and I am having trouble with a migration. ``` python no_newsletter = BooleanField(default=False) migrator.add_column( 'user', 'user_no_newsletter', no_newsletter), ) ``` The SQL issued is: ``` ('ALTER TABLE `user` ADD COLUMN `user_no_newsletter` BOOL', []) ('UPDATE `user` SET `user_no_newsletter` = %s', [False]) ('ALTER TABLE `user` ALTER COLUMN `user_no_newsletter` SET NOT NULL', []) ``` And I get this error for the last query: ``` peewee.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'NOT NULL' at line 1") ``` I had success by manually changing the request to ``` ('ALTER TABLE `user` MODIFY `user_no_newsletter` BOOLEAN NOT NULL', []) ``` Relevant MariaDB docs: https://mariadb.com/kb/en/mariadb/alter-table/ It seems that in MariaDB, ALTER COLUMN cannot be used to enforce NOT NULL on a column. I am no expert nor in peewee nor in MariaDB so it may be me that is making a mistake somewhere. Thanks for peewee !
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/850/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/850/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/849
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/849/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/849/comments
https://api.github.com/repos/coleifer/peewee/issues/849/events
https://github.com/coleifer/peewee/issues/849
132,666,887
MDU6SXNzdWUxMzI2NjY4ODc=
849
Subquery join replaces primary key
{ "login": "purpurpur", "id": 7671808, "node_id": "MDQ6VXNlcjc2NzE4MDg=", "avatar_url": "https://avatars.githubusercontent.com/u/7671808?v=4", "gravatar_id": "", "url": "https://api.github.com/users/purpurpur", "html_url": "https://github.com/purpurpur", "followers_url": "https://api.github.com/users/purpurpur/followers", "following_url": "https://api.github.com/users/purpurpur/following{/other_user}", "gists_url": "https://api.github.com/users/purpurpur/gists{/gist_id}", "starred_url": "https://api.github.com/users/purpurpur/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/purpurpur/subscriptions", "organizations_url": "https://api.github.com/users/purpurpur/orgs", "repos_url": "https://api.github.com/users/purpurpur/repos", "events_url": "https://api.github.com/users/purpurpur/events{/privacy}", "received_events_url": "https://api.github.com/users/purpurpur/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "@embali you should use [code formatting](https://guides.github.com/features/mastering-markdown/#GitHub-flavored-markdown) to make your issue more readable.\n", "Indeed, I'm confused why people expect me to spend time answering the question they were too lazy to write properly.\n", "Try changing the join on the subquery to:\n\n``` python\n .join(\n categories_,\n on=(models.Category.uid == categories_.c.uid).alias('xx'))\\\n```\n" ]
2016-02-10T10:54:59
2016-02-11T15:23:17
2016-02-11T15:23:17
NONE
null
Hello, I have models Category: uid - primary key Tag: uid - primary key CategoryTag: uid - promary key category - foreign key to Category tag - foreign key to Tag And using this to get all categories with tag uid list for each category: ``` python categories_ = models.Category\ .select()\ .paginate(CATEGORIES_COUNT/LIMIT, paginate_by=LIMIT)\ .alias('categories_') categories = models.Category\ .select(models.Category, models.CategoryTag)\ .join( categories_, on=(models.Category.uid == categories_.c.uid))\ .join(models.CategoryTag, join_type=peewee.JOIN.LEFT_OUTER)\ .aggregate_rows() ``` But, after that if I try to get uid (categories[0].uid) for any category it will be an empty list, but not uid value, if it is getting replaced, how can I fix this? Without that joining subqueries is useless
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/849/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/849/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/848
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/848/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/848/comments
https://api.github.com/repos/coleifer/peewee/issues/848/events
https://github.com/coleifer/peewee/pull/848
132,468,838
MDExOlB1bGxSZXF1ZXN0NTg3NzM4Nzc=
848
Use current class as reverse ManyToManyField (cf #838)
{ "login": "yohanboniface", "id": 146023, "node_id": "MDQ6VXNlcjE0NjAyMw==", "avatar_url": "https://avatars.githubusercontent.com/u/146023?v=4", "gravatar_id": "", "url": "https://api.github.com/users/yohanboniface", "html_url": "https://github.com/yohanboniface", "followers_url": "https://api.github.com/users/yohanboniface/followers", "following_url": "https://api.github.com/users/yohanboniface/following{/other_user}", "gists_url": "https://api.github.com/users/yohanboniface/gists{/gist_id}", "starred_url": "https://api.github.com/users/yohanboniface/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/yohanboniface/subscriptions", "organizations_url": "https://api.github.com/users/yohanboniface/orgs", "repos_url": "https://api.github.com/users/yohanboniface/repos", "events_url": "https://api.github.com/users/yohanboniface/events{/privacy}", "received_events_url": "https://api.github.com/users/yohanboniface/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Humm, why? :s\nThat does not seem to hurt anything while allowing more DRYer overriding of ManyToManyField.\n" ]
2016-02-09T16:42:02
2016-03-11T12:52:11
2016-02-20T12:19:59
CONTRIBUTOR
null
Thanks :)
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/848/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/848/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/848", "html_url": "https://github.com/coleifer/peewee/pull/848", "diff_url": "https://github.com/coleifer/peewee/pull/848.diff", "patch_url": "https://github.com/coleifer/peewee/pull/848.patch", "merged_at": null }
https://api.github.com/repos/coleifer/peewee/issues/847
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/847/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/847/comments
https://api.github.com/repos/coleifer/peewee/issues/847/events
https://github.com/coleifer/peewee/issues/847
132,291,124
MDU6SXNzdWUxMzIyOTExMjQ=
847
Database name necessary?
{ "login": "startakovsky", "id": 689723, "node_id": "MDQ6VXNlcjY4OTcyMw==", "avatar_url": "https://avatars.githubusercontent.com/u/689723?v=4", "gravatar_id": "", "url": "https://api.github.com/users/startakovsky", "html_url": "https://github.com/startakovsky", "followers_url": "https://api.github.com/users/startakovsky/followers", "following_url": "https://api.github.com/users/startakovsky/following{/other_user}", "gists_url": "https://api.github.com/users/startakovsky/gists{/gist_id}", "starred_url": "https://api.github.com/users/startakovsky/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/startakovsky/subscriptions", "organizations_url": "https://api.github.com/users/startakovsky/orgs", "repos_url": "https://api.github.com/users/startakovsky/repos", "events_url": "https://api.github.com/users/startakovsky/events{/privacy}", "received_events_url": "https://api.github.com/users/startakovsky/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Peewee needs to know which database to connect to, so yes, this is a requirement.\n" ]
2016-02-08T23:50:09
2016-02-09T01:29:22
2016-02-09T01:29:22
NONE
null
Maybe this is a feature improvement, but why does peewee require the database name in the url? mysql://{username}:{password}@{host}:{port} gives an error for something like this only in peewee, not sqlalchemy.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/847/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/847/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/846
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/846/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/846/comments
https://api.github.com/repos/coleifer/peewee/issues/846/events
https://github.com/coleifer/peewee/pull/846
131,709,756
MDExOlB1bGxSZXF1ZXN0NTg0NjIwNDM=
846
Proposed fix for #845
{ "login": "cledoux", "id": 573298, "node_id": "MDQ6VXNlcjU3MzI5OA==", "avatar_url": "https://avatars.githubusercontent.com/u/573298?v=4", "gravatar_id": "", "url": "https://api.github.com/users/cledoux", "html_url": "https://github.com/cledoux", "followers_url": "https://api.github.com/users/cledoux/followers", "following_url": "https://api.github.com/users/cledoux/following{/other_user}", "gists_url": "https://api.github.com/users/cledoux/gists{/gist_id}", "starred_url": "https://api.github.com/users/cledoux/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/cledoux/subscriptions", "organizations_url": "https://api.github.com/users/cledoux/orgs", "repos_url": "https://api.github.com/users/cledoux/repos", "events_url": "https://api.github.com/users/cledoux/events{/privacy}", "received_events_url": "https://api.github.com/users/cledoux/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Merged a slightly different fix. Thanks for bringing this to my attention.\n" ]
2016-02-05T17:53:57
2016-02-05T18:21:37
2016-02-05T18:21:37
NONE
null
APSWDatabase _connect() without also making a call to _add_conn_hooks(). This was resulting in the pragmas keyword for **init** being ignored as the call to _set_pragmas was never made. I've added test cases that illustrate my original problem and added the call to _add_conn_hooks() to APSWDatabase._connect().
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/846/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/846/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/846", "html_url": "https://github.com/coleifer/peewee/pull/846", "diff_url": "https://github.com/coleifer/peewee/pull/846.diff", "patch_url": "https://github.com/coleifer/peewee/pull/846.patch", "merged_at": null }
https://api.github.com/repos/coleifer/peewee/issues/845
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/845/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/845/comments
https://api.github.com/repos/coleifer/peewee/issues/845/events
https://github.com/coleifer/peewee/issues/845
131,708,614
MDU6SXNzdWUxMzE3MDg2MTQ=
845
APSWDatabase not respecting pragmas keyword.
{ "login": "cledoux", "id": 573298, "node_id": "MDQ6VXNlcjU3MzI5OA==", "avatar_url": "https://avatars.githubusercontent.com/u/573298?v=4", "gravatar_id": "", "url": "https://api.github.com/users/cledoux", "html_url": "https://github.com/cledoux", "followers_url": "https://api.github.com/users/cledoux/followers", "following_url": "https://api.github.com/users/cledoux/following{/other_user}", "gists_url": "https://api.github.com/users/cledoux/gists{/gist_id}", "starred_url": "https://api.github.com/users/cledoux/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/cledoux/subscriptions", "organizations_url": "https://api.github.com/users/cledoux/orgs", "repos_url": "https://api.github.com/users/cledoux/repos", "events_url": "https://api.github.com/users/cledoux/events{/privacy}", "received_events_url": "https://api.github.com/users/cledoux/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "I've created a pull request with test cases that illustrate the issue along with a potential fix.\n\nAPSWDatabase overwrites _connect without calling _add_conn_hooks. I added this missing call.\n", "Thanks for the amazingly fast turnaround!\n" ]
2016-02-05T17:49:03
2016-02-05T18:29:40
2016-02-05T18:21:21
NONE
null
When initializing an apsw database with pragmas, these pragmas seem completly ignored. This problem is not seen in the parent class, SqliteExtDatabase. ``` >>> db = APSWDatabase('/tmp/apsw.sqlite', pragmas=(('journal_mode', 'WAL'),)) >>> db.connect() >>> db.execute_sql('PRAGMA journal_mode;').fetchone()[0] 'delete' >>> db = SqliteExtDatabase('/tmp/sqliteext.sqlite', pragmas=(('journal_mode', 'WAL'),)) >>> db.connect() >>> db.execute_sql('PRAGMA journal_mode;').fetchone()[0] 'wal' ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/845/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/845/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/844
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/844/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/844/comments
https://api.github.com/repos/coleifer/peewee/issues/844/events
https://github.com/coleifer/peewee/pull/844
131,702,491
MDExOlB1bGxSZXF1ZXN0NTg0NTg2Mzc=
844
Allow to make dynamic related name with current class
{ "login": "yohanboniface", "id": 146023, "node_id": "MDQ6VXNlcjE0NjAyMw==", "avatar_url": "https://avatars.githubusercontent.com/u/146023?v=4", "gravatar_id": "", "url": "https://api.github.com/users/yohanboniface", "html_url": "https://github.com/yohanboniface", "followers_url": "https://api.github.com/users/yohanboniface/followers", "following_url": "https://api.github.com/users/yohanboniface/following{/other_user}", "gists_url": "https://api.github.com/users/yohanboniface/gists{/gist_id}", "starred_url": "https://api.github.com/users/yohanboniface/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/yohanboniface/subscriptions", "organizations_url": "https://api.github.com/users/yohanboniface/orgs", "repos_url": "https://api.github.com/users/yohanboniface/repos", "events_url": "https://api.github.com/users/yohanboniface/events{/privacy}", "received_events_url": "https://api.github.com/users/yohanboniface/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "What you have there is really no different from the current behavior. For instance:\n\n``` python\nIn [1]: from peewee import *\n\nIn [2]: class User(Model):\n ...: username = CharField()\n ...: \n\nIn [3]: class BaseTweet(Model):\n ...: user = ForeignKeyField(User)\n ...: \n\nIn [4]: class Tweet(BaseTweet):\n ...: pass\n ...: \n\nIn [5]: class PhotoTweet(BaseTweet):\n ...: pass\n ...: \nIn [6]: User.phototweet_set\nOut[6]: <peewee.ReverseRelationDescriptor at 0x7f42ac136710>\n\nIn [7]: User.tweet_set\nOut[7]: <peewee.ReverseRelationDescriptor at 0x7f42ac136490>\n```\n", "> What you have there is really no different from the current behavior.\n\nWell, I know that. But I want to take control over this naming…\n", "@coleifer can you reconsider this? In my point of view it does not hurt, while allowing user to customize easily related names.\n" ]
2016-02-05T17:26:46
2016-02-09T11:35:20
2016-02-05T18:05:51
CONTRIBUTOR
null
When declaring a ForeignKey in an abstract class, this allows to customize the related_name for each child. For example: ``` python class Other: pass class Abstract: # Will create Other.child1_foo and Other.child2_foo accessors. other = ForeignKey(Other, related_name='{classname}_foo') class Child1(Abstract): pass class Child2(Abstract): pass ``` Thanks :)
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/844/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/844/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/844", "html_url": "https://github.com/coleifer/peewee/pull/844", "diff_url": "https://github.com/coleifer/peewee/pull/844.diff", "patch_url": "https://github.com/coleifer/peewee/pull/844.patch", "merged_at": null }
https://api.github.com/repos/coleifer/peewee/issues/843
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/843/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/843/comments
https://api.github.com/repos/coleifer/peewee/issues/843/events
https://github.com/coleifer/peewee/issues/843
131,022,395
MDU6SXNzdWUxMzEwMjIzOTU=
843
Support for `flat` tuples
{ "login": "alexanderad", "id": 888394, "node_id": "MDQ6VXNlcjg4ODM5NA==", "avatar_url": "https://avatars.githubusercontent.com/u/888394?v=4", "gravatar_id": "", "url": "https://api.github.com/users/alexanderad", "html_url": "https://github.com/alexanderad", "followers_url": "https://api.github.com/users/alexanderad/followers", "following_url": "https://api.github.com/users/alexanderad/following{/other_user}", "gists_url": "https://api.github.com/users/alexanderad/gists{/gist_id}", "starred_url": "https://api.github.com/users/alexanderad/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/alexanderad/subscriptions", "organizations_url": "https://api.github.com/users/alexanderad/orgs", "repos_url": "https://api.github.com/users/alexanderad/repos", "events_url": "https://api.github.com/users/alexanderad/events{/privacy}", "received_events_url": "https://api.github.com/users/alexanderad/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "You can use `more_itertools` to flatten that.\n\n``` python\nIn [1]: import more_itertools\n\nIn [2]: l = [(1,), (2, ), (3, )]\n\nIn [3]: list(more_itertools.flatten(l))\nOut[3]: [1, 2, 3]\n```\n", "I can use `itertools` as well (which is part of stdlib contrary to `more_itertools`), but this is not a question _how_ to do that:\n\n``` python\nIn [4]: list(itertools.chain(*[(1,), (2, ), (3,)]))\nOut[4]: [1, 2, 3]\n```\n\nThis is rather a convenient shortcut.\n", "I'm going to pass on this feature, as it is fairly easy to implement on your own. If you really want, instead of a list of row tuples, a list of scalar values - then you can write either `map(query, operator.itemgetter(0))` or something similar.\n", "+1, programmers are lazy\n" ]
2016-02-03T13:18:30
2016-04-29T07:41:45
2016-02-03T16:50:17
NONE
null
While working with peewee we often query database for a bunch of records on a single field and it is handy in this case to have a flat, chained resultset (functionality similar to [values_list(flat=True)](https://docs.djangoproject.com/en/1.9/ref/models/querysets/#values-list)) So instead of having ``` python >>> User.select(User.id).tuples() [(1,), (2, ), (3, )] ``` I imagine this could be expressed in API like: ``` python >>> User.select(User.id).tuples(flat=True) [1, 2, 3, 4, ...] ``` Can we consider having this on board, @coleifer? I'd work on corresponding PR if this fits the design. /cc @stas
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/843/reactions", "total_count": 3, "+1": 3, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/843/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/842
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/842/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/842/comments
https://api.github.com/repos/coleifer/peewee/issues/842/events
https://github.com/coleifer/peewee/issues/842
130,652,166
MDU6SXNzdWUxMzA2NTIxNjY=
842
Support for MySQL STRAIGHT_JOIN
{ "login": "fmazan", "id": 12230333, "node_id": "MDQ6VXNlcjEyMjMwMzMz", "avatar_url": "https://avatars.githubusercontent.com/u/12230333?v=4", "gravatar_id": "", "url": "https://api.github.com/users/fmazan", "html_url": "https://github.com/fmazan", "followers_url": "https://api.github.com/users/fmazan/followers", "following_url": "https://api.github.com/users/fmazan/following{/other_user}", "gists_url": "https://api.github.com/users/fmazan/gists{/gist_id}", "starred_url": "https://api.github.com/users/fmazan/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/fmazan/subscriptions", "organizations_url": "https://api.github.com/users/fmazan/orgs", "repos_url": "https://api.github.com/users/fmazan/repos", "events_url": "https://api.github.com/users/fmazan/events{/privacy}", "received_events_url": "https://api.github.com/users/fmazan/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Just do this:\n\n``` python\nfrom peewee import *\nJOIN['STRAIGHT'] = 'STRAIGHT'\n\nmy_query = SomeObj.select().join(SomeOther, JOIN.STRAIGHT)\n```\n", "This doesn't work anymore in version 3, due to:\r\n\r\n\r\n```\r\nclass Join(BaseTable):\r\n...\r\n def __sql__(self, ctx):\r\n (ctx\r\n .sql(self.lhs)\r\n .literal(' %s JOIN ' % self.join_type)\r\n .sql(self.rhs))\r\n if self._on is not None:\r\n ctx.literal(' ON ').sql(self._on)\r\n return ctx\r\n```", "Are you sure about that? Seems to work for me:\r\n\r\n```python\r\n\r\nIn [1]: from peewee import *\r\n\r\nIn [2]: JOIN['STRAIGHT'] = 'STRAIGHT'\r\n\r\nIn [3]: class Foo(Model):\r\n ...: pass\r\n ...: \r\n\r\nIn [4]: class Bar(Model):\r\n ...: foo = ForeignKeyField(Foo)\r\n ...: \r\n\r\nIn [5]: query = Bar.select().join(Foo, JOIN.STRAIGHT)\r\n\r\nIn [6]: query.sql()\r\nOut[6]: \r\n('SELECT \"t1\".\"id\", \"t1\".\"foo_id\" FROM \"bar\" AS \"t1\" STRAIGHT JOIN \"foo\" AS \"t2\" ON (\"t1\".\"foo_id\" = \"t2\".\"id\")',\r\n [])\r\n\r\n```", "The problem is that the STRAIGHT_JOIN is written with an underscore, it's not space separated. Oh well, those MySQL quirks...", "Ahh, thanks for the explanation. Let me look into it.", "Yeah, the code doesn't seem to support that very well...going to leave as wontfix for now." ]
2016-02-02T11:18:20
2018-02-26T17:08:36
2018-02-26T17:08:36
NONE
null
Would it be possible to somehow perform STRAIGHT_JOIN on MySQL tables due to its poor query optimizer except using raw SQL query? The syntax according to [http://dev.mysql.com/doc/refman/5.7/en/join.html](http://dev.mysql.com/doc/refman/5.7/en/join.html) is: > join_table: > table_reference [INNER | CROSS] JOIN table_factor [join_condition] > | table_reference STRAIGHT_JOIN table_factor > | table_reference STRAIGHT_JOIN table_factor ON conditional_expr > | table_reference {LEFT|RIGHT} [OUTER] JOIN table_reference join_condition > | table_reference NATURAL [{LEFT|RIGHT} [OUTER]] JOIN table_factor
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/842/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/842/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/841
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/841/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/841/comments
https://api.github.com/repos/coleifer/peewee/issues/841/events
https://github.com/coleifer/peewee/issues/841
130,432,668
MDU6SXNzdWUxMzA0MzI2Njg=
841
Namespace collision with another pip module
{ "login": "n3storm", "id": 220748, "node_id": "MDQ6VXNlcjIyMDc0OA==", "avatar_url": "https://avatars.githubusercontent.com/u/220748?v=4", "gravatar_id": "", "url": "https://api.github.com/users/n3storm", "html_url": "https://github.com/n3storm", "followers_url": "https://api.github.com/users/n3storm/followers", "following_url": "https://api.github.com/users/n3storm/following{/other_user}", "gists_url": "https://api.github.com/users/n3storm/gists{/gist_id}", "starred_url": "https://api.github.com/users/n3storm/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/n3storm/subscriptions", "organizations_url": "https://api.github.com/users/n3storm/orgs", "repos_url": "https://api.github.com/users/n3storm/repos", "events_url": "https://api.github.com/users/n3storm/events{/privacy}", "received_events_url": "https://api.github.com/users/n3storm/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "WTF... I have to say this does not appear to be a peewee issue to me, I'm at a loss. Peewee doesn't do anything weird regarding imports so I'm laying this at the doorstep of the thing that's jacking with imports and doing dark magic.\n", "I have peeked into peewee repo and looks like you are right, so pluginbase must be messing directly with python. FYI, before using peewee this app was running ok using tinydb for storage (and pluginbase).\nI will create an issue at pocoo repo.\n\nThanks Charles.\n", "Well, for whatever reason it's messing up the system path. Peewee import SQLite3, which for some crazy reason goes through pluginbase? But sqlite3 is a part of the standard lib...so that's probably the source of the issue.\n" ]
2016-02-01T17:50:59
2016-02-01T21:38:58
2016-02-01T17:55:47
NONE
null
Looks like if you install peewee and PluginBase from pocoo then python, pluginbase and peewee goes crazy. Took me 1 hour before realizing this. http://pluginbase.pocoo.org/ ``` from goingpostal.contrib.group.models import Member, Queue, Archive, database File "/usr/local/lib/python2.7/dist-packages/pluginbase.py", line 404, in plugin_import fromlist, level) File "/usr/local/lib/python2.7/dist-packages/goingpostal/contrib/group/models.py", line 1, in <module> from peewee import * File "/usr/local/lib/python2.7/dist-packages/pluginbase.py", line 404, in plugin_import fromlist, level) File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 147, in <module> import sqlite3 File "/usr/local/lib/python2.7/dist-packages/pluginbase.py", line 404, in plugin_import fromlist, level) File "/usr/lib/python2.7/sqlite3/__init__.py", line 24, in <module> from dbapi2 import * File "/usr/local/lib/python2.7/dist-packages/pluginbase.py", line 404, in plugin_import fromlist, level) ImportError: No module named dbapi2 ``` Don't know if this has any solution without breaking user API, but I wanted to write it down so somebody else my find it helpful before becoming bald pulling hair. Cheers.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/841/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/841/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/840
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/840/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/840/comments
https://api.github.com/repos/coleifer/peewee/issues/840/events
https://github.com/coleifer/peewee/issues/840
129,981,986
MDU6SXNzdWUxMjk5ODE5ODY=
840
Blog example: werkzeug error
{ "login": "rubensoleao", "id": 7544470, "node_id": "MDQ6VXNlcjc1NDQ0NzA=", "avatar_url": "https://avatars.githubusercontent.com/u/7544470?v=4", "gravatar_id": "", "url": "https://api.github.com/users/rubensoleao", "html_url": "https://github.com/rubensoleao", "followers_url": "https://api.github.com/users/rubensoleao/followers", "following_url": "https://api.github.com/users/rubensoleao/following{/other_user}", "gists_url": "https://api.github.com/users/rubensoleao/gists{/gist_id}", "starred_url": "https://api.github.com/users/rubensoleao/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/rubensoleao/subscriptions", "organizations_url": "https://api.github.com/users/rubensoleao/orgs", "repos_url": "https://api.github.com/users/rubensoleao/repos", "events_url": "https://api.github.com/users/rubensoleao/events{/privacy}", "received_events_url": "https://api.github.com/users/rubensoleao/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "I've noticed that this starts happening when I put youtube videos in my blog entries.\n\nSometimes I also get this error:\n\n> peewee.IntegrityError\n> \n> IntegrityError: UNIQUE constraint failed: entry.slug\n> Traceback (most recent call last)\n> \n> ```\n> File \"/home/lubens/Documents/CACIC/Site/blog/lib/python2.7/site-packages/flask/app.py\", line 1836, in __call__\n> \n> return self.wsgi_app(environ, start_response)\n> \n> File \"/home/lubens/Documents/CACIC/Site/blog/lib/python2.7/site-packages/flask/app.py\", line 1820, in wsgi_app\n> \n> response = self.make_response(self.handle_exception(e))\n> \n> File \"/home/lubens/Documents/CACIC/Site/blog/lib/python2.7/site-packages/flask/app.py\", line 1403, in handle_exception\n> \n> reraise(exc_type, exc_value, tb)\n> \n> File \"/home/lubens/Documents/CACIC/Site/blog/lib/python2.7/site-packages/flask/app.py\", line 1817, in wsgi_app\n> \n> response = self.full_dispatch_request()\n> \n> File \"/home/lubens/Documents/CACIC/Site/blog/lib/python2.7/site-packages/flask/app.py\", line 1477, in full_dispatch_request\n> \n> rv = self.handle_user_exception(e)\n> \n> File \"/home/lubens/Documents/CACIC/Site/blog/lib/python2.7/site-packages/flask/app.py\", line 1381, in handle_user_exception\n> \n> reraise(exc_type, exc_value, tb)\n> \n> File \"/home/lubens/Documents/CACIC/Site/blog/lib/python2.7/site-packages/flask/app.py\", line 1475, in full_dispatch_request\n> \n> rv = self.dispatch_request()\n> \n> File \"/home/lubens/Documents/CACIC/Site/blog/lib/python2.7/site-packages/flask/app.py\", line 1461, in dispatch_request\n> \n> return self.view_functions[rule.endpoint](**req.view_args)\n> \n> File \"/home/lubens/Documents/CACIC/Site/blog/HTML/app.py\", line 148, in inner\n> \n> return fn(*args, **kwargs)\n> \n> File \"/home/lubens/Documents/CACIC/Site/blog/HTML/app.py\", line 201, in create\n> \n> published=request.form.get('published') or False)\n> \n> File \"/home/lubens/Documents/CACIC/Site/blog/lib/python2.7/site-packages/peewee.py\", line 4494, in create\n> \n> inst.save(force_insert=True)\n> \n> File \"/home/lubens/Documents/CACIC/Site/blog/HTML/app.py\", line 86, in save\n> \n> ret = super(Entry, self).save(*args, **kwargs)\n> \n> File \"/home/lubens/Documents/CACIC/Site/blog/lib/python2.7/site-packages/peewee.py\", line 4680, in save\n> \n> pk_from_cursor = self.insert(**field_dict).execute()\n> \n> File \"/home/lubens/Documents/CACIC/Site/blog/lib/python2.7/site-packages/peewee.py\", line 3213, in execute\n> \n> cursor = self._execute()\n> \n> File \"/home/lubens/Documents/CACIC/Site/blog/lib/python2.7/site-packages/peewee.py\", line 2628, in _execute\n> \n> return self.database.execute_sql(sql, params, self.require_commit)\n> \n> File \"/home/lubens/Documents/CACIC/Site/blog/lib/python2.7/site-packages/peewee.py\", line 3461, in execute_sql\n> \n> self.commit()\n> \n> File \"/home/lubens/Documents/CACIC/Site/blog/lib/python2.7/site-packages/peewee.py\", line 3285, in __exit__\n> \n> reraise(new_type, new_type(*exc_args), traceback)\n> \n> File \"/home/lubens/Documents/CACIC/Site/blog/lib/python2.7/site-packages/peewee.py\", line 3454, in execute_sql\n> \n> cursor.execute(sql, params or ())\n> \n> IntegrityError: UNIQUE constraint failed: entry.slug\n> ```\n> \n> The debugger caught an exception in your WSGI application. You can now look at the traceback which led to the error.\n> \n> To switch between the interactive traceback and the plaintext one, you can click on the \"Traceback\" headline. From the text traceback you can also create a paste of it. For code execution mouse-over the frame you want to debug and click on the console icon on the right side.\n> \n> You can execute arbitrary Python code in the stack frames and there are some extra helpers available for introspection:\n> \n> ```\n> dump() shows all variables in the frame\n> dump(obj) dumps all that's known about the object\n> ```\n", "I have no idea what the problem is, but the application itself is fine.\n", "hi , I have the same problem, using python 2.7 and it happens both using uwsgi or the flask built-in server\n", "For me it happens only when I run app in debug mode. Try to run app without debug. @rubensoleao You're right - youtube videos in entries are related to this issue.\n" ]
2016-01-30T12:37:08
2016-05-20T19:03:51
2016-01-30T16:45:04
NONE
null
When I run the blog, I randomly get this werkzeug error. > Exception happened during processing of request from ('127.0.0.1', 38174) > Traceback (most recent call last): > File "/usr/lib/python2.7/SocketServer.py", line 295, in _handle_request_noblock > self.process_request(request, client_address) > File "/usr/lib/python2.7/SocketServer.py", line 321, in process_request > self.finish_request(request, client_address) > File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request > self.RequestHandlerClass(request, client_address, self) > File "/usr/lib/python2.7/SocketServer.py", line 655, in __init__ > self.handle() > File "/home/lubens/Documents/CACIC/Site/blog/local/lib/python2.7/site-packages/werkzeug/serving.py", line 217, in handle > rv = BaseHTTPRequestHandler.handle(self) > File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle > self.handle_one_request() > File "/home/lubens/Documents/CACIC/Site/blog/local/lib/python2.7/site-packages/werkzeug/serving.py", line 248, in handle_one_request > self.raw_requestline = self.rfile.readline() > IOError: [Errno 11] Resource temporarily unavailable Does someone know why that could be? Thank you!
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/840/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/840/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/839
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/839/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/839/comments
https://api.github.com/repos/coleifer/peewee/issues/839/events
https://github.com/coleifer/peewee/issues/839
129,917,578
MDU6SXNzdWUxMjk5MTc1Nzg=
839
Documentation Idea: Alternative way to using same model with multiple databases
{ "login": "shirish93", "id": 3619659, "node_id": "MDQ6VXNlcjM2MTk2NTk=", "avatar_url": "https://avatars.githubusercontent.com/u/3619659?v=4", "gravatar_id": "", "url": "https://api.github.com/users/shirish93", "html_url": "https://github.com/shirish93", "followers_url": "https://api.github.com/users/shirish93/followers", "following_url": "https://api.github.com/users/shirish93/following{/other_user}", "gists_url": "https://api.github.com/users/shirish93/gists{/gist_id}", "starred_url": "https://api.github.com/users/shirish93/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/shirish93/subscriptions", "organizations_url": "https://api.github.com/users/shirish93/orgs", "repos_url": "https://api.github.com/users/shirish93/repos", "events_url": "https://api.github.com/users/shirish93/events{/privacy}", "received_events_url": "https://api.github.com/users/shirish93/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "I don't mean to offend, but this is just basic Python. I don't think it's necessarily worth documenting, but thank you for sharing your thoughts on the issue.\n" ]
2016-01-30T00:16:17
2016-01-30T16:41:15
2016-01-30T16:41:15
NONE
null
Hey @coleifer , I've asked this question in the mailing list, but I believe I've come up with a more elegant idea to use a model with multiple databases. The user defines a Model, but encapsulates it in a function. The function takes the name of the database to be used, and returns the Model that uses the specified database. If this question comes up again, it might be worth it to point people in this direction. Sample: ``` global dbName #Put this dummy value here. It'll be overwritten anyway def makeModel(dbName): global dNname class ModelName: #classDef goes here. class Meta: database = dbName return ModelName ``` To use it: ``` model_for_db1 = makeModel(dbName1) model_for_db2 = makeModel(dbName2) query = model_for_db1.select().where(model_for_db1.field_1 == 'value_1') ``` What is your view with regards to this? Please feel free to remove/close the issue if you feel this does not deserve to be in the 'issues' section. I had a particularly long process trying to find a way to make this work, so I imagine others might gain from it. : )- Update 2: Added a global variable to fix it. It appears to work now. Update 1: Doesn't work as expected. Any sort of specific query doesn't seem to work. I'll close the issue after further testing. Sorry for the false alarm.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/839/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/839/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/838
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/838/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/838/comments
https://api.github.com/repos/coleifer/peewee/issues/838/events
https://github.com/coleifer/peewee/issues/838
129,712,187
MDU6SXNzdWUxMjk3MTIxODc=
838
Custom ManyToManyQuery?
{ "login": "yohanboniface", "id": 146023, "node_id": "MDQ6VXNlcjE0NjAyMw==", "avatar_url": "https://avatars.githubusercontent.com/u/146023?v=4", "gravatar_id": "", "url": "https://api.github.com/users/yohanboniface", "html_url": "https://github.com/yohanboniface", "followers_url": "https://api.github.com/users/yohanboniface/followers", "following_url": "https://api.github.com/users/yohanboniface/following{/other_user}", "gists_url": "https://api.github.com/users/yohanboniface/gists{/gist_id}", "starred_url": "https://api.github.com/users/yohanboniface/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/yohanboniface/subscriptions", "organizations_url": "https://api.github.com/users/yohanboniface/orgs", "repos_url": "https://api.github.com/users/yohanboniface/repos", "events_url": "https://api.github.com/users/yohanboniface/events{/privacy}", "received_events_url": "https://api.github.com/users/yohanboniface/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "See f1988db for the changes.\n", "Thanks for the quick fix @coleifer!\n\nThat fixes the main issues, though I'd still need to overwrite and copy-paste [`ManyToManyFieldDescriptor.__get__`](https://github.com/coleifer/peewee/blob/master/playhouse/fields.py#L169) and [`ManyToManyQuery.clone`](https://github.com/coleifer/peewee/blob/master/playhouse/fields.py#L189), any idea to prevent that too?\n", "Replacing:\n\n```\n def clone(self):\n query = ManyToManyQuery(\n self._instance,\n self._field_descriptor,\n self.model_class)\n query.database = self.database\n return self._clone_attributes(query)\n```\n\nby\n\n```\n def clone(self):\n query = self.__class__(\n self._instance,\n self._field_descriptor,\n self.model_class)\n query.database = self.database\n return self._clone_attributes(query)\n```\n\nwould help without hurting, imho :)\n", "You could probably override `clone()` in your subclass. I think that would\nactually be more appropriate.\n\nOn Tue, Feb 2, 2016 at 4:48 AM, Yohan Boniface [email protected]\nwrote:\n\n> Replacing:\n> \n> ```\n> def clone(self):\n> query = ManyToManyQuery(\n> self._instance,\n> self._field_descriptor,\n> self.model_class)\n> query.database = self.database\n> return self._clone_attributes(query)\n> ```\n> \n> by\n> \n> ```\n> def clone(self):\n> query = self.__class__(\n> self._instance,\n> self._field_descriptor,\n> self.model_class)\n> query.database = self.database\n> return self._clone_attributes(query)\n> ```\n> \n> would help without hurting, imho :)\n> \n> —\n> Reply to this email directly or view it on GitHub\n> https://github.com/coleifer/peewee/issues/838#issuecomment-178504560.\n", "> You could probably override `clone()` in your subclass. I think that would actually be more appropriate.\n\nWhy is that more appropriate?\nIMHO, using `self.__class__` in peewee code does not hurt and make it more generic, preventing users to override `clone` just because they have a custom ManyToManyQuery class.\n" ]
2016-01-29T09:24:12
2016-02-05T14:35:37
2016-01-29T15:46:35
CONTRIBUTOR
null
I'd like to implement a custom result wrapper for my ManyToManyQuery (already done a custom [SelectQuery](https://github.com/etalab/ban/blob/master/ban/db/model.py#L6)), but currently the `ManyToManyQuery` is hardcoded in the [ManyToManyFieldDescriptor](https://github.com/coleifer/peewee/blob/master/playhouse/fields.py#L168) (and in `ManyToManyQuery.clone`), which itself is hardcoded in [ManyToManyField](https://github.com/coleifer/peewee/blob/master/playhouse/fields.py#L116). Would you consider a PR that would make that more customizable? I'm thinking about making those class attributes. Something like this: ``` python # Or maybe better at Field level directly? class ManyToManyField(Field): descriptor_class = ManyToManyFieldDescriptor def add_to_class(self, model_class, name): … setattr(model_class, name, self.descriptor_class(self)) … class ManyToManyFieldDescriptor(FieldDescriptor): query_class = ManyToManyQuery … ``` Thoughts?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/838/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/838/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/837
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/837/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/837/comments
https://api.github.com/repos/coleifer/peewee/issues/837/events
https://github.com/coleifer/peewee/pull/837
129,317,368
MDExOlB1bGxSZXF1ZXN0NTc0NDg1Mzg=
837
fix for issue #836
{ "login": "ronyb29", "id": 1606872, "node_id": "MDQ6VXNlcjE2MDY4NzI=", "avatar_url": "https://avatars.githubusercontent.com/u/1606872?v=4", "gravatar_id": "", "url": "https://api.github.com/users/ronyb29", "html_url": "https://github.com/ronyb29", "followers_url": "https://api.github.com/users/ronyb29/followers", "following_url": "https://api.github.com/users/ronyb29/following{/other_user}", "gists_url": "https://api.github.com/users/ronyb29/gists{/gist_id}", "starred_url": "https://api.github.com/users/ronyb29/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/ronyb29/subscriptions", "organizations_url": "https://api.github.com/users/ronyb29/orgs", "repos_url": "https://api.github.com/users/ronyb29/repos", "events_url": "https://api.github.com/users/ronyb29/events{/privacy}", "received_events_url": "https://api.github.com/users/ronyb29/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "This is not the intended behavior of last_insert_id() -- the intended behavior is to return the last inserted `rowid`. For auto-incrementing primary key fields, this works as expected.\n\nIf you have a user-defined primary key, then presumably you know what it is beforehand so there's no need to return it (and issue an extra query into the bargain).\n", "the thing is, currently, Model.save() sets the pk to whatever the database reports as `last_insert_id`, so when you make relationships with instances created in code (not retrieved from the DB) the foreign key for ForeignKeyField are broken.\n", "Peewee only automatically sets the primary key for auto incremented integers. If you have a uuid primary key you presumably set that in the application. I'm confused as to what issue you're actually experiencing.\n", "Perhaps I have failed to convey the issue. Currently it is setting the PK regardless of its kind to whatever `last_insert_id` returns. Please take a look at this tests.\n\n``` python\nfrom uuid import uuid1, UUID\n\nfrom playhouse.apsw_ext import *\nfrom playhouse.tests.base import ModelTestCase\n\ndb = APSWDatabase(':memory:')\n\nclass BaseModel(Model):\n class Meta:\n database = db\n\nclass Batch(BaseModel):\n id = UUIDField(primary_key=True, default=uuid1)\n\nclass Document(BaseModel):\n id = UUIDField(primary_key=True, default=uuid1)\n batch = ForeignKeyField(Batch, related_name='documents', to_field='id')\n\nclass APSWPKTest(ModelTestCase):\n requires = [Batch, Document]\n\n def test_non_int_pk_saving(self):\n batch = Batch()\n self.assertIsInstance(batch.id, UUID) # passes\n batch.save(force_insert=True) # Will save the right id in the DB, but will modify the instance and set it to the rowid\n self.assertIsInstance(batch.id, UUID) # fails, contains the ROWID returned by last_insert_id\n\n def test_non_int_pk_relationships(self):\n batch = Batch.create()\n self.assertIsInstance(batch.id, UUID) # fails, contains the ROWID returned by last_insert_id\n\n doc = Document(batch=batch)\n self.assertIsInstance(doc.id, UUID) # passes\n doc.save(force_insert=True)\n self.assertIsInstance(doc.id, UUID) # fails, contains the ROWID returned by last_insert_id\n```\n\nThat is because Model.save actually sets the instance pk field after inserting\n\n``` python\nclass Model(with_metaclass(BaseModel)):\n ...\n def save(self, force_insert=False, only=None):\n ...\n self._populate_unsaved_relations(field_dict)\n if pk_value is not None and not force_insert:\n ...\n elif pk_field is None:\n ...\n else:\n pk_from_cursor = self.insert(**field_dict).execute()\n if pk_from_cursor is not None:\n pk_value = pk_from_cursor\n self._set_pk_value(pk_value)\n rows = 1\n self._dirty.clear()\n return rows\n```\n\nPerhaps a better solution than what I originally proposed would be for Model.save to only set the PK if it was an instance of PrimaryKeyField\n" ]
2016-01-28T03:07:29
2016-01-28T15:55:16
2016-01-28T03:20:38
CONTRIBUTOR
null
fix for issue #836
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/837/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/837/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/837", "html_url": "https://github.com/coleifer/peewee/pull/837", "diff_url": "https://github.com/coleifer/peewee/pull/837.diff", "patch_url": "https://github.com/coleifer/peewee/pull/837.patch", "merged_at": null }
https://api.github.com/repos/coleifer/peewee/issues/836
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/836/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/836/comments
https://api.github.com/repos/coleifer/peewee/issues/836/events
https://github.com/coleifer/peewee/issues/836
129,316,867
MDU6SXNzdWUxMjkzMTY4Njc=
836
apsw and non integer PK
{ "login": "ronyb29", "id": 1606872, "node_id": "MDQ6VXNlcjE2MDY4NzI=", "avatar_url": "https://avatars.githubusercontent.com/u/1606872?v=4", "gravatar_id": "", "url": "https://api.github.com/users/ronyb29", "html_url": "https://github.com/ronyb29", "followers_url": "https://api.github.com/users/ronyb29/followers", "following_url": "https://api.github.com/users/ronyb29/following{/other_user}", "gists_url": "https://api.github.com/users/ronyb29/gists{/gist_id}", "starred_url": "https://api.github.com/users/ronyb29/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/ronyb29/subscriptions", "organizations_url": "https://api.github.com/users/ronyb29/orgs", "repos_url": "https://api.github.com/users/ronyb29/repos", "events_url": "https://api.github.com/users/ronyb29/events{/privacy}", "received_events_url": "https://api.github.com/users/ronyb29/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "https://github.com/coleifer/peewee/pull/837#issuecomment-175938671\n", "I see the issue now. Normally, last_insert_id() checks first that the model has an auto incrementing pk.\n\n``` python\ndef last_insert_id(self, cursor, model):\n if model._meta.auto_increment:\n return cursor.lastrowid\n```\n\nThis check is missing in the apsw driver, though. Apologies for the confusion on my part. The fix will just need to add this check to the apsw implementation.\n" ]
2016-01-28T03:04:41
2016-01-29T00:09:15
2016-01-29T00:09:15
CONTRIBUTOR
null
the apsw driver currently returns the last [rowid](https://www.sqlite.org/c3ref/last_insert_rowid.html) instead of the las inserted PK, this causes problems for any non int pk (like a UUID)
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/836/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/836/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/835
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/835/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/835/comments
https://api.github.com/repos/coleifer/peewee/issues/835/events
https://github.com/coleifer/peewee/issues/835
128,818,211
MDU6SXNzdWUxMjg4MTgyMTE=
835
Signal Support and Identifying Models
{ "login": "jimjkelly", "id": 68440, "node_id": "MDQ6VXNlcjY4NDQw", "avatar_url": "https://avatars.githubusercontent.com/u/68440?v=4", "gravatar_id": "", "url": "https://api.github.com/users/jimjkelly", "html_url": "https://github.com/jimjkelly", "followers_url": "https://api.github.com/users/jimjkelly/followers", "following_url": "https://api.github.com/users/jimjkelly/following{/other_user}", "gists_url": "https://api.github.com/users/jimjkelly/gists{/gist_id}", "starred_url": "https://api.github.com/users/jimjkelly/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/jimjkelly/subscriptions", "organizations_url": "https://api.github.com/users/jimjkelly/orgs", "repos_url": "https://api.github.com/users/jimjkelly/repos", "events_url": "https://api.github.com/users/jimjkelly/events{/privacy}", "received_events_url": "https://api.github.com/users/jimjkelly/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "This is not a peewee problem, but a problem with the way you're importing and managing your models.\n\nPython loads your imported modules into memory and you're double-loading them (foo.Model and models.foo.Model). Python sees this as two different modules and in fact they are essentially two different models. What's scarier is you might have two different databases.... I'd strongly consider reorganizing your code as this type of bug can produce weird issues like the one you've posted.\n", "Given the way the models get configured I don't have to worry about two different databases, but I'll be a bit more vigilant about importing them the same way. Thanks!\n" ]
2016-01-26T13:22:59
2016-01-27T11:59:22
2016-01-27T04:42:58
NONE
null
Hi - so I have a setup where I've abstracted my models out into a pip installable package so that they can be used in multiple places in my infrastructure. This works great except when trying to get signals working. Essentially, things aren't working because of the check here: https://github.com/coleifer/peewee/blob/master/playhouse/signals.py#L39 Namely - the instance class is being referred to as `foo.Model` where as outside (i.e. when I wire up a signal handler and give it a sender) it's referred to as `models.foo.Model`. Does that make sense? If not I can try and put together a small example. Given this problem - is it possible instead compare models by name? Or is it not expected that those necessarily be globally unique? Or is there something else obvious maybe I'm missing here to resolve that problem?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/835/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/835/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/834
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/834/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/834/comments
https://api.github.com/repos/coleifer/peewee/issues/834/events
https://github.com/coleifer/peewee/issues/834
128,432,172
MDU6SXNzdWUxMjg0MzIxNzI=
834
Python 3 PasswordField Bug AttributeError encode
{ "login": "mosquito", "id": 792981, "node_id": "MDQ6VXNlcjc5Mjk4MQ==", "avatar_url": "https://avatars.githubusercontent.com/u/792981?v=4", "gravatar_id": "", "url": "https://api.github.com/users/mosquito", "html_url": "https://github.com/mosquito", "followers_url": "https://api.github.com/users/mosquito/followers", "following_url": "https://api.github.com/users/mosquito/following{/other_user}", "gists_url": "https://api.github.com/users/mosquito/gists{/gist_id}", "starred_url": "https://api.github.com/users/mosquito/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/mosquito/subscriptions", "organizations_url": "https://api.github.com/users/mosquito/orgs", "repos_url": "https://api.github.com/users/mosquito/repos", "events_url": "https://api.github.com/users/mosquito/events{/privacy}", "received_events_url": "https://api.github.com/users/mosquito/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "I believe the code was correct, but needed to just check for a unicode type rather than assuming one.\n" ]
2016-01-24T23:11:56
2016-01-25T04:58:24
2016-01-25T04:58:07
NONE
null
The class PasswordHash was inherited from bytes. For python 3 it's wrong because python's 3 bytes not provide "encode" method and this code: ``` class PasswordField(BlobField): def __init__(self, iterations=12, *args, **kwargs): if None in (hashpw, gensalt): raise ValueError('Missing library required for PasswordField: bcrypt') self.bcrypt_iterations = iterations self.raw_password = None super(PasswordField, self).__init__(*args, **kwargs) ``` fails with AttributeError. For me I make a fix: ``` from playhouse.fields import PasswordField as PasswordFieldBase, PasswordHash class PasswordField(PasswordFieldBase): def db_value(self, value): if isinstance(value, PasswordHash): value = value.decode("utf-8") return super(PasswordField, self).db_value(value) ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/834/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/834/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/833
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/833/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/833/comments
https://api.github.com/repos/coleifer/peewee/issues/833/events
https://github.com/coleifer/peewee/issues/833
128,414,857
MDU6SXNzdWUxMjg0MTQ4NTc=
833
Feauture proposal for playhouse: Option to store binary blobs in compressed form
{ "login": "shirish93", "id": 3619659, "node_id": "MDQ6VXNlcjM2MTk2NTk=", "avatar_url": "https://avatars.githubusercontent.com/u/3619659?v=4", "gravatar_id": "", "url": "https://api.github.com/users/shirish93", "html_url": "https://github.com/shirish93", "followers_url": "https://api.github.com/users/shirish93/followers", "following_url": "https://api.github.com/users/shirish93/following{/other_user}", "gists_url": "https://api.github.com/users/shirish93/gists{/gist_id}", "starred_url": "https://api.github.com/users/shirish93/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/shirish93/subscriptions", "organizations_url": "https://api.github.com/users/shirish93/orgs", "repos_url": "https://api.github.com/users/shirish93/repos", "events_url": "https://api.github.com/users/shirish93/events{/privacy}", "received_events_url": "https://api.github.com/users/shirish93/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "You should check the `CompressedField`. It supports zlib and bz2.\n\nhttp://docs.peewee-orm.com/en/latest/peewee/playhouse.html#CompressedField\n", "Oh dear! Totally missed out on that. Thanks!\n" ]
2016-01-24T18:14:57
2016-01-24T21:00:47
2016-01-24T20:48:05
NONE
null
Hello, I've been working with peewee lately, and since my data is a lot of repeating text information, it's being compressed. It would seem that such a feature might be useful for everyday peewee users too, considering that most common compression algorithms have much shorter decompression times than compression times (and assuming that most peewee users do database reads more often than db writes). Would such an addition be aligned with your vision of the project? If so, I would start working on it, and the unit tests. There might be a little guidance required with the internal workings of peewee, but besides that, not too much. Not sure if the proposal would fit with playhouse, or core peewee either. Here's an example usage of the proposed feature: During model definition: ` myLargeContiguousString = BlobField(compressed= True) ` for access: ` Model.myLargeContiguousString.select().get() ` would return a decompressed version. I am not sure if returning raw compressed strings would be worth it, and it would be upon you to decide on the syntax for such a feature, but such a feature would be made available too, as per your decision. A good documentation would be needed to tell people about the encodings and as such (my proposal: default to 'utf-8' unless they ask for something else), and that they would gain the most by compressing only larger strings, etcetera, maybe even a choice between bz2 and zlib (both available in Python core) but that's about the design decisions I can think of. The work of writing up the documentation would obviously be on me, with your guidance. Thoughts?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/833/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/833/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/832
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/832/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/832/comments
https://api.github.com/repos/coleifer/peewee/issues/832/events
https://github.com/coleifer/peewee/issues/832
128,328,386
MDU6SXNzdWUxMjgzMjgzODY=
832
Support for RethinkDB
{ "login": "foxx", "id": 651797, "node_id": "MDQ6VXNlcjY1MTc5Nw==", "avatar_url": "https://avatars.githubusercontent.com/u/651797?v=4", "gravatar_id": "", "url": "https://api.github.com/users/foxx", "html_url": "https://github.com/foxx", "followers_url": "https://api.github.com/users/foxx/followers", "following_url": "https://api.github.com/users/foxx/following{/other_user}", "gists_url": "https://api.github.com/users/foxx/gists{/gist_id}", "starred_url": "https://api.github.com/users/foxx/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/foxx/subscriptions", "organizations_url": "https://api.github.com/users/foxx/orgs", "repos_url": "https://api.github.com/users/foxx/repos", "events_url": "https://api.github.com/users/foxx/events{/privacy}", "received_events_url": "https://api.github.com/users/foxx/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Sure, a rethinkdb backend would be pretty neat!\n", "Okay awesome, I'll let you know once I have something ready for review (an early preview would be appreciated, as you can spot any design flaws much sooner!)\n", "What's going on with this issue? You know, as I'm thinking about it, this would probably benefit from being a separate package. To that effect, I think I will close this out.\n", "Apologies for the lack of replies on this, this was shelved in favour of getting some other functionality working first, however I do plan on coming back to this eventually. I'll create a separate package for this, and we can always consider merging it into playhouse at a later date.\n" ]
2016-01-23T13:26:21
2016-03-13T21:01:31
2016-03-13T19:26:45
CONTRIBUTOR
null
I'm looking at the possibility of adding support for [RethinkDB](https://www.rethinkdb.com/) into Peewee. It recently became stable and so far looks absolutely [amazing](http://rob.conery.io/2015/04/17/rethinkdb-2-0-is-amazing/). After looking at some of the other extensions in playhouse, this seems to be a straight forward task. However I'm struggling to decide what components should be abstracted, for example, there's a lot of functionality relating to [sharding/replication](https://www.rethinkdb.com/docs/sharding-and-replication/), which might make it difficult to use as a generic layer in Peewee. There's a cheat sheet [here](https://www.rethinkdb.com/docs/sql-to-reql/javascript/) showing comparison of SQL to ReQL. In my use case, I've built several modules with auditing and metrics capabilities, which are re-usable between applications. For some users, they might suffice with just using Postgres but in other situations like mine, these need to scale to billions of rows. If I was able to add support into Peewee for RethinkDB, then I can reduce the amount of database specific work (e.g. having to specifically add support for both Peewee and RethinkDB API). Anyway I'd be interested to hear your thoughts on whether RethinkDB would be a suitable candidate for playhouse. I'll be working on a prototype in `peewee-extras` over the next month, so any thoughts/feedback/hints would be much appreciated. It will likely be another 6-8 weeks until `peewee-extras` is stable and clean with documentation though (it's still a building site at the moment!)
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/832/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/832/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/831
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/831/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/831/comments
https://api.github.com/repos/coleifer/peewee/issues/831/events
https://github.com/coleifer/peewee/issues/831
128,223,567
MDU6SXNzdWUxMjgyMjM1Njc=
831
Unable to install in Windows + Python3
{ "login": "shirish93", "id": 3619659, "node_id": "MDQ6VXNlcjM2MTk2NTk=", "avatar_url": "https://avatars.githubusercontent.com/u/3619659?v=4", "gravatar_id": "", "url": "https://api.github.com/users/shirish93", "html_url": "https://github.com/shirish93", "followers_url": "https://api.github.com/users/shirish93/followers", "following_url": "https://api.github.com/users/shirish93/following{/other_user}", "gists_url": "https://api.github.com/users/shirish93/gists{/gist_id}", "starred_url": "https://api.github.com/users/shirish93/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/shirish93/subscriptions", "organizations_url": "https://api.github.com/users/shirish93/orgs", "repos_url": "https://api.github.com/users/shirish93/repos", "events_url": "https://api.github.com/users/shirish93/events{/privacy}", "received_events_url": "https://api.github.com/users/shirish93/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Just saw https://github.com/coleifer/peewee/issues/763 . Closing this as it is a duplicate.\n" ]
2016-01-22T19:12:27
2016-01-22T19:13:38
2016-01-22T19:13:38
NONE
null
When trying to install peewee in Windows (with WinPython), I get the following error: ` copying playhouse\__init__.py -> build\lib.win32-3.4\playhouse running build_ext cythoning playhouse/speedups.pyx to playhouse\speedups.c building 'playhouse._speedups' extension error: Unable to find vcvarsall.bat ` This SO thread http://stackoverflow.com/questions/33834113/fail-to-install-peewee-under-winpython suggests that the solution would be as follows: ` init_sqlite_ext is the wrong PyMODINIT_FUNC to call on Python 3. It should be PyInit__sqlite_ext ` Would you be able to test this, and make the necessary change? (I could put in a pull request for it, if it is so desired...)
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/831/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/831/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/830
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/830/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/830/comments
https://api.github.com/repos/coleifer/peewee/issues/830/events
https://github.com/coleifer/peewee/issues/830
127,900,863
MDU6SXNzdWUxMjc5MDA4NjM=
830
Support for SmallInteger
{ "login": "foxx", "id": 651797, "node_id": "MDQ6VXNlcjY1MTc5Nw==", "avatar_url": "https://avatars.githubusercontent.com/u/651797?v=4", "gravatar_id": "", "url": "https://api.github.com/users/foxx", "html_url": "https://github.com/foxx", "followers_url": "https://api.github.com/users/foxx/followers", "following_url": "https://api.github.com/users/foxx/following{/other_user}", "gists_url": "https://api.github.com/users/foxx/gists{/gist_id}", "starred_url": "https://api.github.com/users/foxx/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/foxx/subscriptions", "organizations_url": "https://api.github.com/users/foxx/orgs", "repos_url": "https://api.github.com/users/foxx/repos", "events_url": "https://api.github.com/users/foxx/events{/privacy}", "received_events_url": "https://api.github.com/users/foxx/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "No, I'll whip up an implementation, seems useful.\n", "Beautiful, thank you!\n" ]
2016-01-21T11:09:40
2016-01-21T15:06:17
2016-01-21T14:56:51
CONTRIBUTOR
null
Doesn't appear to be a cross database compatible field for representing `smallint`. [Postgres](http://www.postgresql.org/docs/9.1/static/datatype-numeric.html), [MySQL](https://dev.mysql.com/doc/refman/5.5/en/integer-types.html) and [SQLite](https://www.sqlite.org/datatype3.html) seem to handle `smallint` in the same way, with the exception of SQLite casting all `smallint` to `int`. Any objections for adding this to the core? Happy to send a PR if needed
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/830/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/830/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/829
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/829/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/829/comments
https://api.github.com/repos/coleifer/peewee/issues/829/events
https://github.com/coleifer/peewee/issues/829
127,861,796
MDU6SXNzdWUxMjc4NjE3OTY=
829
too many clients already
{ "login": "strongant", "id": 7685936, "node_id": "MDQ6VXNlcjc2ODU5MzY=", "avatar_url": "https://avatars.githubusercontent.com/u/7685936?v=4", "gravatar_id": "", "url": "https://api.github.com/users/strongant", "html_url": "https://github.com/strongant", "followers_url": "https://api.github.com/users/strongant/followers", "following_url": "https://api.github.com/users/strongant/following{/other_user}", "gists_url": "https://api.github.com/users/strongant/gists{/gist_id}", "starred_url": "https://api.github.com/users/strongant/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/strongant/subscriptions", "organizations_url": "https://api.github.com/users/strongant/orgs", "repos_url": "https://api.github.com/users/strongant/repos", "events_url": "https://api.github.com/users/strongant/events{/privacy}", "received_events_url": "https://api.github.com/users/strongant/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "This just means your database is rejecting the connection because there are too many clients connected.\n", "I don't see how this is a peewee issue. Probably check your connection management code, maybe you're not properly closing connections.\n\nIn the future please provide some shred of useful information in a ticket, otherwise you're just wasting my time and yours.\n" ]
2016-01-21T07:18:11
2016-01-21T14:30:16
2016-01-21T14:30:16
NONE
null
OperationalError: FATAL: sorry, too many clients already FATAL: sorry, too many clients already
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/829/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/829/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/828
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/828/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/828/comments
https://api.github.com/repos/coleifer/peewee/issues/828/events
https://github.com/coleifer/peewee/issues/828
127,820,252
MDU6SXNzdWUxMjc4MjAyNTI=
828
Make signals respect transactions?
{ "login": "josefdlange", "id": 1062835, "node_id": "MDQ6VXNlcjEwNjI4MzU=", "avatar_url": "https://avatars.githubusercontent.com/u/1062835?v=4", "gravatar_id": "", "url": "https://api.github.com/users/josefdlange", "html_url": "https://github.com/josefdlange", "followers_url": "https://api.github.com/users/josefdlange/followers", "following_url": "https://api.github.com/users/josefdlange/following{/other_user}", "gists_url": "https://api.github.com/users/josefdlange/gists{/gist_id}", "starred_url": "https://api.github.com/users/josefdlange/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/josefdlange/subscriptions", "organizations_url": "https://api.github.com/users/josefdlange/orgs", "repos_url": "https://api.github.com/users/josefdlange/repos", "events_url": "https://api.github.com/users/josefdlange/events{/privacy}", "received_events_url": "https://api.github.com/users/josefdlange/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Or, just a thought that popped into my head, maybe on [`transaction`](https://github.com/coleifer/peewee/blob/master/peewee.py#L3995) we could add in the ability to set a callable value to be executed on commit? (and rollback I suppose).\n", "Peewee is active record, so the concept of tracking models throughout a transaction is not really included in the design. SQLAlchemy, on the other hand, supports this type of thing. Django, too, might via a post-commit signal handler but I'm not positive.\n\nWhat I'd suggest to you is to implement a wrapper of `transaction` that accepts a list of callbacks...you might write something like:\n\n``` python\nclass MyTransaction(transaction):\n def __init__(self, db):\n super(MyTransaction, self).__init__(db)\n self.callbacks = []\n\n def bind(self, callback):\n self.callbacks.append(callback)\n\n def commit(self):\n super(MyTransaction, self).commit()\n for callback in self.callbacks:\n callback()\n```\n\nPeewee provides the primitives, I guess is what I'm saying, and it should be possible for you to build the type of system you want on top of them. Whether they are a part of the core or not is a judgment call, and perhaps I'll add a post-commit hook but this should hopefully help you get started.\n", "I'd also note that using `transaction` is really not preferred, the preferred way is to use `db.atomic()` (which can be a context manager or decorator). The reason being that `atomic()` will use the appropriate APIs -- transactions and savepoints -- depending on the level of nesting. Whereas if you're just using transaction() only the outer-most layer is run in a transaction and any nested layers are effectively no-ops.\n", "Yes, I do use atomic(), which I see just obfuscates when to use transaction() vs savepoint(). As a curiosity since I don't have the code in front of me, does a savepoint know about its parent transaction?\n\n> On Jan 21, 2016, at 9:04 AM, Charles Leifer [email protected] wrote:\n> \n> I'd also note that using transaction is really not preferred, the preferred way is to use db.atomic() (which can be a context manager or decorator). The reason being that atomic() will use the appropriate APIs -- transactions and savepoints -- depending on the level of nesting. Whereas if you're just using transaction() only the outer-most layer is run in a transaction and any nested layers are effectively no-ops.\n> \n> —\n> Reply to this email directly or view it on GitHub.\n" ]
2016-01-21T00:52:41
2016-01-21T15:53:53
2016-01-21T15:02:56
CONTRIBUTOR
null
I have a feeling the answer will be "no, definitely not" but I thought I'd pick your brain on this. I've got a variety of functions that do a variety of things, some calling others, etc, and some of these functions in effect send push notifications and the like to clients based on the data they've created/changed/interpreted. The clients then receive those notifications and query my web application for data in some cases. Sometimes, the push messages get to the clients so quickly that in fact the work which is happening inside a transaction isn't yet complete and the transaction not yet committed to the DB, which causes the clients to be very sad and think they've been sent a message for nonexistent data. I'm using `falcon` which could in theory allow me to pass its request context structure down into all my functions, but that doesn't work with the decoupled nature of signals, and a majority of these messages are sent via model signals, since typically I want to update my end-users based on some change in data. I'm trying to think if there is a pragmatic way to implement a `post_commit` signal to respect a transaction's committing. The key would be somehow having the model identify that it is within a transaction, and then enqueue the `@post_commit`-decorated function in the transaction object at save time to be called when `commit()` is called. Seems messy. Seems silly. But I'm curious if it's _possible_. My solution right now is to defer sending the message into `celery` with a delay, but that's not really a solution, it's more of a shitty hack. An alternate thought is to be able to get a list of rows/Model instances affected by a transaction we're about to commit, but that seems equally silly... Anyway, curious if you have any ideas.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/828/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/828/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/827
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/827/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/827/comments
https://api.github.com/repos/coleifer/peewee/issues/827/events
https://github.com/coleifer/peewee/issues/827
127,659,957
MDU6SXNzdWUxMjc2NTk5NTc=
827
Support for sophisticated migrations
{ "login": "foxx", "id": 651797, "node_id": "MDQ6VXNlcjY1MTc5Nw==", "avatar_url": "https://avatars.githubusercontent.com/u/651797?v=4", "gravatar_id": "", "url": "https://api.github.com/users/foxx", "html_url": "https://github.com/foxx", "followers_url": "https://api.github.com/users/foxx/followers", "following_url": "https://api.github.com/users/foxx/following{/other_user}", "gists_url": "https://api.github.com/users/foxx/gists{/gist_id}", "starred_url": "https://api.github.com/users/foxx/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/foxx/subscriptions", "organizations_url": "https://api.github.com/users/foxx/orgs", "repos_url": "https://api.github.com/users/foxx/repos", "events_url": "https://api.github.com/users/foxx/events{/privacy}", "received_events_url": "https://api.github.com/users/foxx/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "I've always maintained the view that anything beyond the APIs currently available would be best suited for a third party package, and I believe maybe one or two such exist. Any type of automatic schema migrator seems like an invitation to disaster and will never be included as part of peewee.\n", "Thanks for the quick reply, sounds good, I'll have a think about how this might be implemented as a third party module and will follow up for feedback at a later date.\n", "@foxx Have a look to https://github.com/klen/peewee_migrate\n" ]
2016-01-20T11:10:59
2016-03-28T18:39:06
2016-01-20T14:24:35
CONTRIBUTOR
null
As mentioned in [Peewee Docs](http://docs.peewee-orm.com/en/latest/peewee/playhouse.html#schema-migrations); > This engine provides the basis on which a more sophisticated tool could some day be built. Other framework implementations, such as South and Django Migrations, are quite infuriating to use so I'd be interested to hear your thoughts on how such a tool would be constructed @coleifer. Would this tool be within the scope of Peewee core or playhouse? If so, are there any plans on the roadmap to start working on such a tool? I can put a certain amount of time towards helping out with this, so if it needs volunteers then count me in.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/827/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/827/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/826
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/826/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/826/comments
https://api.github.com/repos/coleifer/peewee/issues/826/events
https://github.com/coleifer/peewee/issues/826
127,607,004
MDU6SXNzdWUxMjc2MDcwMDQ=
826
[Feature Req] Ability to order by column with NULL preference
{ "login": "alexlatchford", "id": 628146, "node_id": "MDQ6VXNlcjYyODE0Ng==", "avatar_url": "https://avatars.githubusercontent.com/u/628146?v=4", "gravatar_id": "", "url": "https://api.github.com/users/alexlatchford", "html_url": "https://github.com/alexlatchford", "followers_url": "https://api.github.com/users/alexlatchford/followers", "following_url": "https://api.github.com/users/alexlatchford/following{/other_user}", "gists_url": "https://api.github.com/users/alexlatchford/gists{/gist_id}", "starred_url": "https://api.github.com/users/alexlatchford/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/alexlatchford/subscriptions", "organizations_url": "https://api.github.com/users/alexlatchford/orgs", "repos_url": "https://api.github.com/users/alexlatchford/repos", "events_url": "https://api.github.com/users/alexlatchford/events{/privacy}", "received_events_url": "https://api.github.com/users/alexlatchford/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "I do not plan on supporting that as a Meta option, but you can write a wrapper method on your model class that sorts the table correctly. You can pass arbitrary SQL nodes into order_by(), so:\n\nMyModel.select().order_by(SQL('the_col nulls last'))\n", "Awesome! Thought it might be possible but wasn't sure how, thanks Charles for the answer :smile: \n" ]
2016-01-20T05:21:20
2016-01-20T21:45:55
2016-01-20T14:19:07
CONTRIBUTOR
null
Currently you can use the `order_by` metaclass property to assign default sort ordering. I have a requirement to be able to sort a column and also have it respect sort order for nulls, I've been looking through the docs and can't seem to find support for it so I'd like to propose a syntax for potentially adding the feature in lieu of a PR. Something like: ``` class MyModel(Model): start = DateTimeField(null=True) stop = DateTimeField(null=True) class Meta: order_by = (('-start', 'nulls'), ('nulls', '-stop')) ``` This extends the current syntax and uses it's tuple position to signify NULLS FIRST/LAST. I'm not 100% happy with it but it'll do the job for sure, let me know your thoughts. PS. I'm using Postgres which supports this operation, not sure how the other supported databases handle this interaction, for reference: http://www.postgresql.org/docs/current/static/queries-order.html
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/826/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/826/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/825
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/825/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/825/comments
https://api.github.com/repos/coleifer/peewee/issues/825/events
https://github.com/coleifer/peewee/issues/825
127,497,081
MDU6SXNzdWUxMjc0OTcwODE=
825
Allow Meta `database` to be callable
{ "login": "foxx", "id": 651797, "node_id": "MDQ6VXNlcjY1MTc5Nw==", "avatar_url": "https://avatars.githubusercontent.com/u/651797?v=4", "gravatar_id": "", "url": "https://api.github.com/users/foxx", "html_url": "https://github.com/foxx", "followers_url": "https://api.github.com/users/foxx/followers", "following_url": "https://api.github.com/users/foxx/following{/other_user}", "gists_url": "https://api.github.com/users/foxx/gists{/gist_id}", "starred_url": "https://api.github.com/users/foxx/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/foxx/subscriptions", "organizations_url": "https://api.github.com/users/foxx/orgs", "repos_url": "https://api.github.com/users/foxx/repos", "events_url": "https://api.github.com/users/foxx/events{/privacy}", "received_events_url": "https://api.github.com/users/foxx/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "In the event that callable support is not added to the core, here is the updated version of the monkeypatch which can be injected at any point during the runtime. There is a discussion in #804 about why this approach is required for some patches (due to bugs in Python core).\n\n``` python\ndef ModelOptions__getattribute__(self, key):\n orig = lambda: super(peewee.ModelOptions, self).__getattribute__(key)\n if key == 'database':\n db = orig()\n return db(self) if callable(db) else db\n return orig()\npeewee.ModelOptions.__getattribute__ = ModelOptions__getattribute__\n```\n", "Thinking about this a bit, the solution I've come up with is to allow providing a custom base class for the `ModelOptions`. You can see one way of implementing a dynamic database in e773c620de3d7dc686dab3c2325e02d1e86407d6\n\nDoes this address the issue?\n", "Cloning this locally now for testing, will update shortly\n", "This worked beautifully, +1 from me.\n\nMy usage was slightly different than the one shown in test.\n\n``` python\nfrom peewee import peewee\n\nclass CallableDatabaseMixin(object):\n @property\n def database(self):\n if callable(self._database):\n return self._database(self)\n return self._database\n\n @database.setter\n def database(self, value):\n self._database = value\n\n\nclass CustomModelOptions(CallableDatabaseMixin, peewee.ModelOptions):\n pass\n\n\nclass CustomModel(peewee.Model):\n class Meta:\n model_options_base = CustomModelOptions\n\ndb = peewee.SqliteDatabase(':memory:')\n\nclass A(CustomModel):\n class Meta:\n database = lambda meta: db\n\n\nclass B(CustomModel):\n class Meta:\n database = db\n\n\nassert A._meta.database == db\nassert B._meta.database == db\n```\n", "Awesome\n", "PS) Thanks again for the quick turnaround!\n", "@coleifer Any chance of an updated release with this functionality?\n", "Ahh, yeah I will try and take care of that in the next couple days.\n" ]
2016-01-19T17:26:27
2016-02-12T14:33:58
2016-01-20T16:48:29
CONTRIBUTOR
null
As per other issues, I'm currently implementing a database router and connection manager for Peewee. This allows me to do stuff like; ``` python class User(Model): class Meta: # in this example, current_app() is a global context manager which # uses thread locals to determine the current application being used # in combination with Bottle. It's kinda like ExecutionContext, but for # applications instead database = lambda: current_app().databases['default'] ``` This approach relies on Peewee allowing callables (or properties) being passed into ModelOptions, something which is not currently supported. I've been able to workaround this by using the following monkey patch; ``` python import peewee class CustomModelOptions(peewee.ModelOptions): @property def database(self): if callable(self._database): return self._database() return self._database @database.setter def database(self, value): self._database = value peewee.ModelOptions = CustomModelOptions ``` The advantages of such a patch are; - Provides an alternative to those that /really/ want `Proxy()` - Allows database routers and connection managers to be implemented without monkey patching or subclassing `BaseModel`. @coleifer Would such functionality be merged into the core, obviously implemented in a cleaner fashion, if it had a good PR?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/825/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/825/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/824
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/824/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/824/comments
https://api.github.com/repos/coleifer/peewee/issues/824/events
https://github.com/coleifer/peewee/issues/824
127,141,809
MDU6SXNzdWUxMjcxNDE4MDk=
824
Using ArrayField w/ BinaryJSONField (PostgreSQL)
{ "login": "tantona", "id": 6251606, "node_id": "MDQ6VXNlcjYyNTE2MDY=", "avatar_url": "https://avatars.githubusercontent.com/u/6251606?v=4", "gravatar_id": "", "url": "https://api.github.com/users/tantona", "html_url": "https://github.com/tantona", "followers_url": "https://api.github.com/users/tantona/followers", "following_url": "https://api.github.com/users/tantona/following{/other_user}", "gists_url": "https://api.github.com/users/tantona/gists{/gist_id}", "starred_url": "https://api.github.com/users/tantona/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/tantona/subscriptions", "organizations_url": "https://api.github.com/users/tantona/orgs", "repos_url": "https://api.github.com/users/tantona/repos", "events_url": "https://api.github.com/users/tantona/events{/privacy}", "received_events_url": "https://api.github.com/users/tantona/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Well...since JSON fields themselves can contain arrays, I'm not sure how crucial I feel it is to address this use-case. If peewee is not supporting this, then I'll just defer and mark this wontfix.\n" ]
2016-01-18T02:17:53
2016-01-18T16:12:21
2016-01-18T16:12:21
NONE
null
I was unable to use these two postgres extensions in conjunction. I scoured the internet for an answer but all I found was http://stackoverflow.com/questions/18099589/postgres-array-of-json-avoid-casting My solution (which is a hack) was this ``` def postgresJsonArrayString(array): return "".join(["{", ", ".join(["".join(["\"", json.dumps(m).replace('"', "\\\""), "\""]) for m in array]), "}"]) ``` I realize it's gross but it does the job for now! I was going to circle back on this but at least this gets me back on track! love this library - keep up the great work!
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/824/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/824/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/823
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/823/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/823/comments
https://api.github.com/repos/coleifer/peewee/issues/823/events
https://github.com/coleifer/peewee/pull/823
127,044,673
MDExOlB1bGxSZXF1ZXN0NTYyNTk3MDc=
823
PaginatedQuery should not throw 404 on empty query
{ "login": "econne01", "id": 3346056, "node_id": "MDQ6VXNlcjMzNDYwNTY=", "avatar_url": "https://avatars.githubusercontent.com/u/3346056?v=4", "gravatar_id": "", "url": "https://api.github.com/users/econne01", "html_url": "https://github.com/econne01", "followers_url": "https://api.github.com/users/econne01/followers", "following_url": "https://api.github.com/users/econne01/following{/other_user}", "gists_url": "https://api.github.com/users/econne01/gists{/gist_id}", "starred_url": "https://api.github.com/users/econne01/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/econne01/subscriptions", "organizations_url": "https://api.github.com/users/econne01/orgs", "repos_url": "https://api.github.com/users/econne01/repos", "events_url": "https://api.github.com/users/econne01/events{/privacy}", "received_events_url": "https://api.github.com/users/econne01/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "The behavior is intended\n", "I see. Ok, thanks\n" ]
2016-01-16T18:32:21
2016-01-16T18:37:33
2016-01-16T18:36:37
NONE
null
Working through the [Flask Blog in an hour or less tutorial](https://github.com/econne01/peewee.git), I noticed 404 errors are being thrown when the database is empty. I think `PaginatedQuery` class should gracefully handle an empty query and return empty set when the query returns no results.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/823/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/823/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/823", "html_url": "https://github.com/coleifer/peewee/pull/823", "diff_url": "https://github.com/coleifer/peewee/pull/823.diff", "patch_url": "https://github.com/coleifer/peewee/pull/823.patch", "merged_at": null }
https://api.github.com/repos/coleifer/peewee/issues/822
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/822/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/822/comments
https://api.github.com/repos/coleifer/peewee/issues/822/events
https://github.com/coleifer/peewee/pull/822
126,897,182
MDExOlB1bGxSZXF1ZXN0NTYxODM4NzA=
822
_is_closed check doesn't work with PooledMySQLDatabase and pymysql
{ "login": "decoratorz", "id": 8288881, "node_id": "MDQ6VXNlcjgyODg4ODE=", "avatar_url": "https://avatars.githubusercontent.com/u/8288881?v=4", "gravatar_id": "", "url": "https://api.github.com/users/decoratorz", "html_url": "https://github.com/decoratorz", "followers_url": "https://api.github.com/users/decoratorz/followers", "following_url": "https://api.github.com/users/decoratorz/following{/other_user}", "gists_url": "https://api.github.com/users/decoratorz/gists{/gist_id}", "starred_url": "https://api.github.com/users/decoratorz/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/decoratorz/subscriptions", "organizations_url": "https://api.github.com/users/decoratorz/orgs", "repos_url": "https://api.github.com/users/decoratorz/repos", "events_url": "https://api.github.com/users/decoratorz/events{/privacy}", "received_events_url": "https://api.github.com/users/decoratorz/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Nice, I tested this out and it appears to work correctly. Thanks!\n" ]
2016-01-15T15:40:44
2016-01-15T22:16:33
2016-01-15T22:16:21
NONE
null
We encountered the same problem as described here: https://github.com/coleifer/peewee/issues/783 Our connections in the pool were closed by MySQL with the 2006 error after reaching server-side timeout. Because we don't always control the environment we run in, we didn't want to guess the my.cnf wait_timeout value and hardcode it in the `stale_timeout` argument for Pool, we just always need to restart a dead connection. But the solution was simple. The main problem lies [here](https://github.com/coleifer/peewee/blob/7857f08a6fb70fc91c8e884d9eaa2289155d29f5/playhouse/pool.py#L168). This check doesn't work, because `pymysql.connection` also has the `open` attribute (at least in our version 0.6.6). We could use some other method to differentiate between pymysql and MySQLdb, but there is actually no need. Even though `conn.ping` always [returns None](https://github.com/farcepest/MySQLdb1/blob/d236bb7f6b45f81f0156c4a0cfdef2319ba825d9/_mysql.c#L2011) on MySQLdb, it still does the right thing: throws exception on a dead connection. After this fix PooledMySQLDatabase recognizes closed connections and everything works good.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/822/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/822/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/822", "html_url": "https://github.com/coleifer/peewee/pull/822", "diff_url": "https://github.com/coleifer/peewee/pull/822.diff", "patch_url": "https://github.com/coleifer/peewee/pull/822.patch", "merged_at": null }
https://api.github.com/repos/coleifer/peewee/issues/821
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/821/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/821/comments
https://api.github.com/repos/coleifer/peewee/issues/821/events
https://github.com/coleifer/peewee/pull/821
126,782,731
MDExOlB1bGxSZXF1ZXN0NTYxMTY3OTc=
821
Fallback gracefully in the face of ancient (and probably broken) Cython versions
{ "login": "jherre", "id": 391020, "node_id": "MDQ6VXNlcjM5MTAyMA==", "avatar_url": "https://avatars.githubusercontent.com/u/391020?v=4", "gravatar_id": "", "url": "https://api.github.com/users/jherre", "html_url": "https://github.com/jherre", "followers_url": "https://api.github.com/users/jherre/followers", "following_url": "https://api.github.com/users/jherre/following{/other_user}", "gists_url": "https://api.github.com/users/jherre/gists{/gist_id}", "starred_url": "https://api.github.com/users/jherre/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/jherre/subscriptions", "organizations_url": "https://api.github.com/users/jherre/orgs", "repos_url": "https://api.github.com/users/jherre/repos", "events_url": "https://api.github.com/users/jherre/events{/privacy}", "received_events_url": "https://api.github.com/users/jherre/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Where did you arrive at that version number? I'm leery of merging this as I think it might cause some false positives.\n", "I ran a matrix of all versions of Cython since 0.21 using py27, py34 and py35 using the peewee tests.\n\nUsing versions prior to 0.22.1 doesn't work. Failures happen during cythonization. If it's able to install, all tests pass. Trying to install peewee with any version prior to Cython==0.21.1 will fail.\n", "What about py26? Peewee officially supports python 2.6.\n", "Yep, same result on python26. Using versions of Cython earlier than 0.21.1 will cause setup to fail.\n\nIt's really about what versions of Cython you're will to support for speedups. I think it's fair to say that folks need to upgrade to use the speedups in peewee but it's not fair to say they have to upgrade just to use peewee at all...\n\nFWIW, Cython 0.22.1 was released 2014-10-18 which is really not that long ago in Python2.6 terms.\n" ]
2016-01-15T00:47:47
2016-01-15T21:54:41
2016-01-15T21:54:41
NONE
null
Some folks have dependencies that won't support easy Cython upgrades. Ignore incompatible Cython installations - same thing as not having it at all... Tested on py27, py34 and py35 and all versions of Cython up to 0.23.4
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/821/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/821/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/821", "html_url": "https://github.com/coleifer/peewee/pull/821", "diff_url": "https://github.com/coleifer/peewee/pull/821.diff", "patch_url": "https://github.com/coleifer/peewee/pull/821.patch", "merged_at": null }
https://api.github.com/repos/coleifer/peewee/issues/820
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/820/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/820/comments
https://api.github.com/repos/coleifer/peewee/issues/820/events
https://github.com/coleifer/peewee/issues/820
126,746,981
MDU6SXNzdWUxMjY3NDY5ODE=
820
cython compilation failing w/ python3.4
{ "login": "jherre", "id": 391020, "node_id": "MDQ6VXNlcjM5MTAyMA==", "avatar_url": "https://avatars.githubusercontent.com/u/391020?v=4", "gravatar_id": "", "url": "https://api.github.com/users/jherre", "html_url": "https://github.com/jherre", "followers_url": "https://api.github.com/users/jherre/followers", "following_url": "https://api.github.com/users/jherre/following{/other_user}", "gists_url": "https://api.github.com/users/jherre/gists{/gist_id}", "starred_url": "https://api.github.com/users/jherre/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/jherre/subscriptions", "organizations_url": "https://api.github.com/users/jherre/orgs", "repos_url": "https://api.github.com/users/jherre/repos", "events_url": "https://api.github.com/users/jherre/events{/privacy}", "received_events_url": "https://api.github.com/users/jherre/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Python 3.4.3\nCython version 0.21.1\ngcc version 4.9.2 (Ubuntu 4.9.2-10ubuntu13) \n", "Try upgrading your Cython?\n", "Using Python 3.5 and Cython 0.23.4 no issues.\n", "Using Python 3.4.3 and Cython 0.23.4 also no issues\n", "So that is to confirm that it works correctly after upgrading your Cython?\n", "the same error\n$ cython -V\nCython version 0.23.4\n$ python -V\nPython 2.7.6\n`------------------------------------------------------------\n\n...\n\n```\ncdef:\n\n set model_set = set(models)\n\n set seen = set()\n\n list accum = []\n\n\n\nfor model in sorted(model_set, key=_sort_key, reverse=True):\n\n ^\n```\n\n---\n\nplayhouse/speedups.pyx:318:48: Cannot convert 'tuple (object)' to Python object\n\nbuilding 'playhouse._speedups' extension\n\ncreating build/temp.linux-x86_64-2.7\n\ncreating build/temp.linux-x86_64-2.7/playhouse\n\nx86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c playhouse/speedups.c -o build/temp.linux-x86_64-2.7/playhouse/speedups.o\n\nplayhouse/speedups.c:1:2: error: #error Do not use this file, it is the result of a failed Cython compilation.\n\n #error Do not use this file, it is the result of a failed Cython compilation.\n\n ^\n\nerror: command 'x86_64-linux-gnu-gcc' failed with exit status 1\n`\n" ]
2016-01-14T21:00:31
2016-02-05T08:36:11
2016-01-14T21:29:53
NONE
null
Will update with more details as I find time. Pinning to peewee 2.7 for now ``` Running setup.py install for peewee Complete output from command /vagrant/.tox/py34/bin/python3.4 -c "import setuptools, tokenize;__file__='/tmp/pip-build-gasvyut8/peewee/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-mczyxnc7-record/install-record.txt --single-version-externally-managed --compile --install-headers /vagrant/.tox/py34/include/site/python3.4/peewee: running install running build running build_py running build_ext cythoning playhouse/speedups.pyx to playhouse/speedups.c building 'playhouse._speedups' extension x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.4m -I/vagrant/.tox/py34/include/python3.4m -c playhouse/speedups.c -o build/temp.linux-x86_64-3.4/playhouse/speedups.o playhouse/speedups.c:1:2: error: #error Do not use this file, it is the result of a failed Cython compilation. #error Do not use this file, it is the result of a failed Cython compilation. ^ Error compiling Cython file: ------------------------------------------------------------ ... cdef: set model_set = set(models) set seen = set() list accum = [] for model in sorted(model_set, key=_sort_key, reverse=True): ^ ------------------------------------------------------------ playhouse/speedups.pyx:318:48: Cannot convert 'tuple (object)' to Python object error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/820/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/820/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/819
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/819/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/819/comments
https://api.github.com/repos/coleifer/peewee/issues/819/events
https://github.com/coleifer/peewee/pull/819
126,706,589
MDExOlB1bGxSZXF1ZXN0NTYwNjc0MDg=
819
Fixed broken BlobField/BinaryField in MySQL
{ "login": "foxx", "id": 651797, "node_id": "MDQ6VXNlcjY1MTc5Nw==", "avatar_url": "https://avatars.githubusercontent.com/u/651797?v=4", "gravatar_id": "", "url": "https://api.github.com/users/foxx", "html_url": "https://github.com/foxx", "followers_url": "https://api.github.com/users/foxx/followers", "following_url": "https://api.github.com/users/foxx/following{/other_user}", "gists_url": "https://api.github.com/users/foxx/gists{/gist_id}", "starred_url": "https://api.github.com/users/foxx/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/foxx/subscriptions", "organizations_url": "https://api.github.com/users/foxx/orgs", "repos_url": "https://api.github.com/users/foxx/repos", "events_url": "https://api.github.com/users/foxx/events{/privacy}", "received_events_url": "https://api.github.com/users/foxx/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "This will need sign off and review from @coleifer before merge. I'm about 90% happy with the code, but there could be some edge cases I haven't considered.\n", "I'm leaning towards killing off the binary field altogether.\n", "@coleifer Yeah I just updated the original issue with my conclusion, lemme know your thoughts\n", "Closing as per #818 \n" ]
2016-01-14T17:32:59
2016-01-14T21:35:07
2016-01-14T21:35:07
CONTRIBUTOR
null
Fixes #818
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/819/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/819/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/819", "html_url": "https://github.com/coleifer/peewee/pull/819", "diff_url": "https://github.com/coleifer/peewee/pull/819.diff", "patch_url": "https://github.com/coleifer/peewee/pull/819.patch", "merged_at": null }
https://api.github.com/repos/coleifer/peewee/issues/818
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/818/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/818/comments
https://api.github.com/repos/coleifer/peewee/issues/818/events
https://github.com/coleifer/peewee/issues/818
126,690,880
MDU6SXNzdWUxMjY2OTA4ODA=
818
BinaryField/BlobField/UUIDField is broken with MySQL
{ "login": "foxx", "id": 651797, "node_id": "MDQ6VXNlcjY1MTc5Nw==", "avatar_url": "https://avatars.githubusercontent.com/u/651797?v=4", "gravatar_id": "", "url": "https://api.github.com/users/foxx", "html_url": "https://github.com/foxx", "followers_url": "https://api.github.com/users/foxx/followers", "following_url": "https://api.github.com/users/foxx/following{/other_user}", "gists_url": "https://api.github.com/users/foxx/gists{/gist_id}", "starred_url": "https://api.github.com/users/foxx/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/foxx/subscriptions", "organizations_url": "https://api.github.com/users/foxx/orgs", "repos_url": "https://api.github.com/users/foxx/repos", "events_url": "https://api.github.com/users/foxx/events{/privacy}", "received_events_url": "https://api.github.com/users/foxx/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Just looking into this a bit deeper, it seems that `BlobField` is actually broken in MySQL as well, as data was being truncated and not detected by tests, due to [this](https://github.com/coleifer/peewee/blob/master/playhouse/tests/test_fields.py#L320). As you can see, the test was referencing `blob` rather than `res`.\n\nI'm also seeing a /lot/ of warnings locally;\n\n```\n/vagrant/peewee/peewee.py:3480: Warning: Unknown table 'testmodelb'\n cursor.execute(sql, params or ())\n/vagrant/peewee/peewee.py:3480: Warning: Unknown table 'testmodela'\n cursor.execute(sql, params or ())\n/vagrant/peewee/peewee.py:3480: Warning: Unknown table 'computer'\n cursor.execute(sql, params or ())\n```\n\nPR coming shortly, not sure if all the tests are working because getting the test suite to run locally for postgres seems to be troublesome, seeing lots of this;\n\n```\nTraceback (most recent call last):\n File \"/vagrant/peewee/playhouse/tests/base.py\", line 284, in setUp\n test_db.drop_tables(self.requires, True)\n File \"/vagrant/peewee/peewee.py\", line 3597, in drop_tables\n drop_model_tables(models, fail_silently=safe, cascade=cascade)\n File \"/vagrant/peewee/peewee.py\", line 4901, in drop_model_tables\n m.drop_table(**drop_table_kwargs)\n File \"/vagrant/peewee/peewee.py\", line 4633, in drop_table\n cls._meta.database.drop_table(cls, fail_silently, cascade)\n File \"/vagrant/peewee/peewee.py\", line 3594, in drop_table\n model_class, fail_silently, cascade))\n File \"/vagrant/peewee/peewee.py\", line 3487, in execute_sql\n self.commit()\n File \"/vagrant/peewee/peewee.py\", line 3311, in __exit__\n reraise(new_type, new_type(*exc_args), traceback)\n File \"/vagrant/peewee/peewee.py\", line 3480, in execute_sql\n cursor.execute(sql, params or ())\nInternalError: current transaction is aborted, commands ignored until end of transaction block\n```\n\nIt might be worth adding a `Vagrantfile` with a provisioner so that people can contribute and run the test suite without any hassle of setting up a container environment themselves, I'll raise another issue for this though.\n\nPR coming now\n", "Alright I've narrowed it down, the concept of `BinaryField` in MySQL and Postgres is very different. `BINARY` and `VARBINARY` require a `max_length` where as Postgres `BYTEA` doesn't have such an option.\n\nThese field types are fundamentally incompatible between databases, and therefore I have modified the tests to only support `BinaryField` and `FixedBinaryField` with MySQL. \n\nAn alternative solution is to add a conditional into `get_modifiers()` which checks `isinstance(self._meta.database, MySQLDatabase)` and make it not return a modifier if the database doesn't match MySQL. I wasn't sure if this was a violation of Peewee design pattern though.\n\n@coleifer Thoughts?\n", "Looks like changing `get_modifiers()` is working pretty well, updated PR to follow.\n", "After smashing my head against a brick wall for the last few hours, I've finally come to the conclusion that my PR for `BinaryField` and `UUIDField` were completely flawed.\n\nUsing `get_modifiers()` is not really an option because it results in different field behaviour between each database. For example, postgres would allow an unlimited data value size, where as MySQL would not.\n\nI would argue that the usage of `BinaryField` and `UUIDField` in MySQL are so limited, and in fact, almost no one in their right mind would use `UUIDField` in MySQL using the current `VARCHAR(255)` type, so all we've done is add unnecessary complexity to the core.\n\nTherefore my next proposal would be to create `playhouse.mysql` and move those two fields into that module. If that isn't accepted, then I would probably vote to have `BinaryField` removed entirely, because in their current implementation they just cause confusion and problems. I'd also vote to have `VARCHAR(255)` removed from `UUIDField`\n\nI've left my PR open anyway so you can see how I came to this conclusion.\n\nPS) Apologies for causing so much wasted time with this, I should have used these two fields in dev and prod for a few months before submitting ;/\n", "Honestly, I haven't really read the comments... I'm just looking at the code and I don't see how there's a problem unless this test is just completely broken:\n\n``` python\n @skip_test_unless(lambda: isinstance(test_db, MySQLDatabase))\n def test_blob_and_binary_field_mysql(self):\n def inner(cls):\n data = bytes(bytearray(range(256)))\n blob = cls.create(data=Param(data))\n res = cls.get(cls.id == blob.id)\n self.assertEqual(blob.data, data)\n\n inner(BlobModel)\n```\n\nIt appears to be comparing the saved object's `data` field with a 256-byte string.\n", "Oh shit, ok now I read your comments haha ...\n", "Tbh the easiest fix for all of this is to just rip out my `UUIDField` and `BinaryField` PRs. I'll be adding a better abstraction into `peewee_extras` for both of these, and if they are stable after a couple of months prod usage, then we could re-assess putting them into playhouse? If it helps I can send a PR for this.\n", "I killed `BinaryField` and made `UUIDField` a VARCHAR(40), which seemed more appropriate but perhaps you have a better idea for that one. I think that putting them into a `playhouse.mysql_ext` module is a good solution. I have neither the inclination nor the perseverance to try and figure out what is going on with MySQL, so shoving things into a module where they can't hurt anybody is fine.\n", "Completely agreed, and in hindsight I should have done this from the beginning. Since our last discussion I've actually moved over to Postgres, after suffering horrible problems with JSON columns in MariaDB. Once I've got `peewee-extras` stable for a few months I will make an effort to submit a PR for `playhouse.mysql_ext` at a later date, as I hate to leave a job unfinished. Apologies again for all the time wasting, I owe you a few hours of contributor time!\n", "> suffering horrible problems with JSON columns in MariaDB. \n\nWhen you have a few minutes to spare, I'd be curious what went wrong. Or what didn't work like you expected there.\n", "So basically MariaDB supports JSON via [`column_json`](https://mariadb.com/kb/en/mariadb/column_json/) at query time, rather than a data type in schema, which visually looks quite strange. But this gets even stranger when using [dynamic columns](https://mariadb.com/kb/en/mariadb/dynamic-columns-in-mariadb-10/), to the point that the syntax is almost incomprehensible. There are some usage examples [here](http://stackoverflow.com/questions/23087105/mariadb-dynamic-columns-json), and trying to make these work with an ORM would be painful at best.\n\nFrom what I can tell, `column_json` is converting the data to JSON on each blob read, which from a performance standpoint would most likely be significantly worse when compared to Postgres, which has native JSON type support. I believe dynamic columns are supposed to improve this, but the syntax is poor.\n\nThen there is the lack of native UUID type, it can be argued that these could be easily stored as BINARY() but this makes for harder readability for debugging, especially when inspecting pcaps for debugging purposes.\n\nOverall MariaDB has a lot of improvements over MySQL, and I have a huge amount of respect for the work that Monty and the team are doing, but they have really dropped the ball with UUID and JSON support, sadly.\n\nI've ran out of time to do any more work on it this week, but I'll be following up with a blog post showing the performance of UUID field in Postgres, as I'm curious to know whether they have fixed the slow inserts problem, or whether `OrderedUUIDField` would still be needed. (based on that percona [article](https://www.percona.com/blog/2014/12/19/store-uuid-optimized-way/) I mentioned a few months back)\n", "Awesome, thanks for the info! Please send me a link to your blog, love to\ntake a read.\nOn Jan 14, 2016 5:27 PM, \"Cal Leeming\" [email protected] wrote:\n\n> So basically MariaDB supports JSON via column_json\n> https://mariadb.com/kb/en/mariadb/column_json/ at query time, rather\n> than a data type in schema, which visually looks quite strange. But this\n> gets even stranger when using dynamic columns\n> https://mariadb.com/kb/en/mariadb/dynamic-columns-in-mariadb-10/, to\n> the point that the syntax is almost incomprehensible. There are some usage\n> examples here\n> http://stackoverflow.com/questions/23087105/mariadb-dynamic-columns-json,\n> and trying to make these work with an ORM would be painful at best.\n> \n> From what I can tell, column_json is converting the data to JSON on each\n> blob read, which from a performance standpoint would most likely be\n> significantly worse when compared to Postgres, which has native JSON type\n> support. I believe dynamic columns are supposed to improve this, but the\n> syntax is poor.\n> \n> Then there is the lack of native UUID types, it can be argued that these\n> could be easily stored as BINARY() but this makes for harder readability\n> for debugging, especially when inspecting pcaps for debugging purposes.\n> \n> Overall MariaDB has a lot of improvements over MySQL, and I have a huge\n> amount of respect for the work that Monty and the team are doing, but they\n> have really dropped the ball with UUID and JSON support, sadly.\n> \n> I've ran out of time to do any more work on it this week, but I'll be\n> following up with a blog post showing the performance of UUID field in\n> Postgres, as I'm curious to know whether they have fixed the slow inserts\n> problem, or whether OrderedUUIDField would still be needed. (based on\n> that percona article\n> https://www.percona.com/blog/2014/12/19/store-uuid-optimized-way/ I\n> mentioned a few months back)\n> \n> —\n> Reply to this email directly or view it on GitHub\n> https://github.com/coleifer/peewee/issues/818#issuecomment-171815713.\n" ]
2016-01-14T16:28:20
2016-01-23T13:18:55
2016-01-14T23:01:55
CONTRIBUTOR
null
Looks like both `BlobField` and `BinaryField` in MySQL are actually broken, because MySQL expects a `max_length`, and thus all values are being truncated down to 1 byte. The most obvious fix seems to be; ``` class BinaryField(BlobField): db_field = 'varbinary' class FixedBinaryField(CharField): db_field = 'binary' ``` The test should then probably be updated to include a `data` value comparison, and then add the appropriate database mappings after. Submitting PR shortly
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/818/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/818/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/817
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/817/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/817/comments
https://api.github.com/repos/coleifer/peewee/issues/817/events
https://github.com/coleifer/peewee/pull/817
126,681,524
MDExOlB1bGxSZXF1ZXN0NTYwNTE4Njc=
817
Proposal to rename `safe` to `fail_silently`
{ "login": "foxx", "id": 651797, "node_id": "MDQ6VXNlcjY1MTc5Nw==", "avatar_url": "https://avatars.githubusercontent.com/u/651797?v=4", "gravatar_id": "", "url": "https://api.github.com/users/foxx", "html_url": "https://github.com/foxx", "followers_url": "https://api.github.com/users/foxx/followers", "following_url": "https://api.github.com/users/foxx/following{/other_user}", "gists_url": "https://api.github.com/users/foxx/gists{/gist_id}", "starred_url": "https://api.github.com/users/foxx/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/foxx/subscriptions", "organizations_url": "https://api.github.com/users/foxx/orgs", "repos_url": "https://api.github.com/users/foxx/repos", "events_url": "https://api.github.com/users/foxx/events{/privacy}", "received_events_url": "https://api.github.com/users/foxx/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[]
2016-01-14T15:45:45
2016-01-14T16:32:35
2016-01-14T16:32:35
CONTRIBUTOR
null
There seems to be two keywords that have the same meaning, `safe` and `fail_silently`. Is there any reason not to use one, rather than both? PS) This will need a docs update before it can be merged. PS) This is also backwards incompatible
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/817/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/817/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/817", "html_url": "https://github.com/coleifer/peewee/pull/817", "diff_url": "https://github.com/coleifer/peewee/pull/817.diff", "patch_url": "https://github.com/coleifer/peewee/pull/817.patch", "merged_at": null }
https://api.github.com/repos/coleifer/peewee/issues/816
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/816/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/816/comments
https://api.github.com/repos/coleifer/peewee/issues/816/events
https://github.com/coleifer/peewee/issues/816
126,452,409
MDU6SXNzdWUxMjY0NTI0MDk=
816
Support for model mixins?
{ "login": "foxx", "id": 651797, "node_id": "MDQ6VXNlcjY1MTc5Nw==", "avatar_url": "https://avatars.githubusercontent.com/u/651797?v=4", "gravatar_id": "", "url": "https://api.github.com/users/foxx", "html_url": "https://github.com/foxx", "followers_url": "https://api.github.com/users/foxx/followers", "following_url": "https://api.github.com/users/foxx/following{/other_user}", "gists_url": "https://api.github.com/users/foxx/gists{/gist_id}", "starred_url": "https://api.github.com/users/foxx/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/foxx/subscriptions", "organizations_url": "https://api.github.com/users/foxx/orgs", "repos_url": "https://api.github.com/users/foxx/repos", "events_url": "https://api.github.com/users/foxx/events{/privacy}", "received_events_url": "https://api.github.com/users/foxx/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "@foxx, try with:\n\n```\nclass BaseModelMixin(Model):\n```\n", "@yohanboniface has it right.\n", "Additional nit, you don't need `unique=True` for a primary key.\n", "Ahh okay, so the mixins have to have subclass `Model`, I'm guessing due to metaclass magic of some sort. Looks to be working now, thanks both :) (also will remove `unique=True`, ty)\n" ]
2016-01-13T16:06:31
2016-01-13T16:34:18
2016-01-13T16:31:19
CONTRIBUTOR
null
Currently it's not possible to do the following; ``` python class BaseModelMixin(object): id = UUIDField(default=uuid1, primary_key=True, unique=True) class BaseModel(BaseModelMixin, Model): pass class User(BaseModel): pass ``` It's surprising behaviour that I can't construct models from a set of mixins, are there any plans to support this? If not, could you give some insight into why?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/816/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/816/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/815
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/815/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/815/comments
https://api.github.com/repos/coleifer/peewee/issues/815/events
https://github.com/coleifer/peewee/issues/815
126,390,428
MDU6SXNzdWUxMjYzOTA0Mjg=
815
Incorrect SQL generated for OVER clause
{ "login": "liato", "id": 47819, "node_id": "MDQ6VXNlcjQ3ODE5", "avatar_url": "https://avatars.githubusercontent.com/u/47819?v=4", "gravatar_id": "", "url": "https://api.github.com/users/liato", "html_url": "https://github.com/liato", "followers_url": "https://api.github.com/users/liato/followers", "following_url": "https://api.github.com/users/liato/following{/other_user}", "gists_url": "https://api.github.com/users/liato/gists{/gist_id}", "starred_url": "https://api.github.com/users/liato/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/liato/subscriptions", "organizations_url": "https://api.github.com/users/liato/orgs", "repos_url": "https://api.github.com/users/liato/repos", "events_url": "https://api.github.com/users/liato/events{/privacy}", "received_events_url": "https://api.github.com/users/liato/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Instead of using `.challenge_id` can you use `.challenge` instead? Let me know. PS I had to reformat your code so I could read it without scrolling -- please add linebreaks for long chunks of code.\n", "Closing. Please reopen if this does not address your concern.\n", "Thanks! Stupid mistake by me. Using `.challenge` instead of `.challenge_id` worked perfectly.\n", "Not stupid at all, glad that helped.\n" ]
2016-01-13T10:40:33
2016-01-14T12:09:24
2016-01-14T05:03:13
NONE
null
I'm trying to implement sub ordering on my table based on the `challenge_id`field using the following peewee query: ``` python (ChallengeResult .select( ChallengeResult, fn.row_number().over( partition_by=[ChallengeResult.challenge_id], order_by=[ChallengeResult.length.desc()]).alias("row_number")) .where(ChallengeResult.user == user).alias("rows")) ``` This should generate the following SQL: ``` sql (' SELECT "t1"."id", "t1"."created_at", "t1"."user_id", "t1"."challenge_id", "t1"."length", row_number() OVER ( PARTITION BY "t1"."challenge_id" ORDER BY "t1"."length" DESC) AS row_number FROM "challenge_result" AS t1 WHERE ("t1"."user_id" = %s)', [2]) ``` and return these results: ``` id | created_at | user_id | challenge_id | length | row_number -----+----------------------------+---------+--------------+--------+------------ 149 | 2016-01-12 08:45:30.534326 | 2 | 2 | 200 | 1 151 | 2016-01-12 08:57:27.233171 | 2 | 11 | 101 | 1 150 | 2016-01-12 08:57:21.597426 | 2 | 11 | 100 | 2 ``` For some reason the `PARTITION BY` clause in the `OVER` clause is missing the table field and the generated SQL looks like: ``` sql (' SELECT "t1"."id", "t1"."created_at", "t1"."user_id", "t1"."challenge_id", "t1"."length", row_number() OVER ( PARTITION BY %s ORDER BY "t1"."length" DESC) AS row_number FROM "challenge_result" AS t1 WHERE ("t1"."user_id" = %s)', [None, 2]) ``` Returning these results: ``` id | created_at | user_id | challenge_id | length | row_number -----+----------------------------+---------+--------------+--------+------------ 149 | 2016-01-12 08:45:30.534326 | 2 | 2 | 200 | 1 151 | 2016-01-12 08:57:27.233171 | 2 | 11 | 101 | 2 150 | 2016-01-12 08:57:21.597426 | 2 | 11 | 100 | 3 ``` Using peewee 2.7.4, python 3.4.0 and postgresql 9.3.9.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/815/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/815/timeline
null
completed
null
null