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
unknown
updated_at
unknown
closed_at
unknown
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/2719
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/2719/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/2719/comments
https://api.github.com/repos/coleifer/peewee/issues/2719/events
https://github.com/coleifer/peewee/issues/2719
1,692,808,474
I_kwDOAA7yGM5k5jUa
2,719
PeeWee ForeignKeyField error. IntegrityError: (1215, 'Cannot add foreign key constraint')
{ "login": "Ezyhoo", "id": 43151697, "node_id": "MDQ6VXNlcjQzMTUxNjk3", "avatar_url": "https://avatars.githubusercontent.com/u/43151697?v=4", "gravatar_id": "", "url": "https://api.github.com/users/Ezyhoo", "html_url": "https://github.com/Ezyhoo", "followers_url": "https://api.github.com/users/Ezyhoo/followers", "following_url": "https://api.github.com/users/Ezyhoo/following{/other_user}", "gists_url": "https://api.github.com/users/Ezyhoo/gists{/gist_id}", "starred_url": "https://api.github.com/users/Ezyhoo/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/Ezyhoo/subscriptions", "organizations_url": "https://api.github.com/users/Ezyhoo/orgs", "repos_url": "https://api.github.com/users/Ezyhoo/repos", "events_url": "https://api.github.com/users/Ezyhoo/events{/privacy}", "received_events_url": "https://api.github.com/users/Ezyhoo/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "It is probably not recommended to put the UNIQUE in the field definitions since these are already primary keys:\r\n\r\n```python\r\nclass UnsignedBigAutoField(pw.BigAutoField):\r\n field_type = 'BIGINT UNSIGNED AUTO_INCREMENT'\r\n\r\nclass UnsignedAutoField(pw.AutoField):\r\n field_type = 'INT UNSIGNED AUTO_INCREMENT'\r\n```\r\n\r\nThe issue is that Peewee sees your subclass of `BigAutoField` and infers that it should use BIGINT instead of BIGINT UNSIGNED. The fix is to override the `field_type` on the foreign-key, e.g.:\r\n\r\n```python\r\n\r\nclass UnsignedForeignKey(pw.ForeignKeyField):\r\n field_type = 'BIGINT UNSIGNED'\r\n\r\nclass Ticket(MySQLModel):\r\n id = UnsignedBigAutoField(primary_key=True)\r\n user = UnsignedForeignKeyField(User, backref=\"tickets\", field=\"id\", on_delete=\"RESTRICT\", on_update=\"CASCADE\")\r\n date_created = pw.DateTimeField(default=datetime.datetime.now)\r\n```" ]
"2023-05-02T17:26:01"
"2023-05-02T19:42:51"
"2023-05-02T19:42:05"
NONE
null
I have code like below: ``` import datetime import peewee as pw import os my_db = pw.MySQLDatabase(database=os.getenv("DB_NAME"), host=os.getenv("DB_HOST"), port=os.getenv("DB_PORT"), user=os.getenv("DB_USER"), passwd=os.getenv("DB_PASSWORD") class MySQLModel(pw.Model): """A base model class that will use MySQL""" class Meta: database = my_db class UnsignedBigAutoField(pw.BigAutoField): field_type = 'BIGINT UNSIGNED UNIQUE AUTO_INCREMENT' class UnsignedAutoField(pw.AutoField): field_type = 'INT UNSIGNED UNIQUE AUTO_INCREMENT' class User(MySQLModel): id = UnsignedBigAutoField(primary_key=True) alias = pw.CharField(max_length=16, unique=True, null=False) date_created = pw.DateTimeField(default=datetime.datetime.now) class Ticket(MySQLModel): id = UnsignedBigAutoField(primary_key=True) user = pw.ForeignKeyField(User, backref="tickets", field="id", on_delete="RESTRICT", on_update="CASCADE") date_created = pw.DateTimeField(default=datetime.datetime.now) my_db.create_tables([User, Ticket]) ``` The last line of the code when creating ForeignKey produces error: > peewee.IntegrityError: (1215, 'Cannot add foreign key constraint') I checked the datatype(Bitint), and unique/non-null flag are all setup correctly for User table. Couldn't figure out what went wrong here. I created the ForeignKey in MySqlWorkBench manually in Ticket table without a problem. Any help would be appreciated.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/2719/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/2719/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/2718
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/2718/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/2718/comments
https://api.github.com/repos/coleifer/peewee/issues/2718/events
https://github.com/coleifer/peewee/issues/2718
1,692,807,469
I_kwDOAA7yGM5k5jEt
2,718
Fastapi db connection doc
{ "login": "AndyJiangIsTaken", "id": 87741207, "node_id": "MDQ6VXNlcjg3NzQxMjA3", "avatar_url": "https://avatars.githubusercontent.com/u/87741207?v=4", "gravatar_id": "", "url": "https://api.github.com/users/AndyJiangIsTaken", "html_url": "https://github.com/AndyJiangIsTaken", "followers_url": "https://api.github.com/users/AndyJiangIsTaken/followers", "following_url": "https://api.github.com/users/AndyJiangIsTaken/following{/other_user}", "gists_url": "https://api.github.com/users/AndyJiangIsTaken/gists{/gist_id}", "starred_url": "https://api.github.com/users/AndyJiangIsTaken/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/AndyJiangIsTaken/subscriptions", "organizations_url": "https://api.github.com/users/AndyJiangIsTaken/orgs", "repos_url": "https://api.github.com/users/AndyJiangIsTaken/repos", "events_url": "https://api.github.com/users/AndyJiangIsTaken/events{/privacy}", "received_events_url": "https://api.github.com/users/AndyJiangIsTaken/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "The FastAPI docs have a thorough section, I probably need to just link it since your comment is correct and my docs may be misleading.\r\n\r\nhttps://fastapi.tiangolo.com/advanced/sql-databases-peewee/#make-peewee-async-compatible-peeweeconnectionstate", "Updated doc here: http://docs.peewee-orm.com/en/latest/peewee/database.html#fastapi" ]
"2023-05-02T17:25:10"
"2023-05-02T17:48:16"
"2023-05-02T17:34:10"
NONE
null
Hi, Here's the peewee doc I'm referring to: https://docs.peewee-orm.com/en/latest/peewee/database.html#fastapi According to the FastAPI doc, the startup & shutdown events are for when the application, not request here: https://fastapi.tiangolo.com/advanced/events/#startup-event Let me know I'm missing something, new here.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/2718/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/2718/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/2717
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/2717/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/2717/comments
https://api.github.com/repos/coleifer/peewee/issues/2717/events
https://github.com/coleifer/peewee/issues/2717
1,690,728,970
I_kwDOAA7yGM5kxnoK
2,717
Calling save fails when PK is provided but record does not exist yet.
{ "login": "keiranjprice101", "id": 44777678, "node_id": "MDQ6VXNlcjQ0Nzc3Njc4", "avatar_url": "https://avatars.githubusercontent.com/u/44777678?v=4", "gravatar_id": "", "url": "https://api.github.com/users/keiranjprice101", "html_url": "https://github.com/keiranjprice101", "followers_url": "https://api.github.com/users/keiranjprice101/followers", "following_url": "https://api.github.com/users/keiranjprice101/following{/other_user}", "gists_url": "https://api.github.com/users/keiranjprice101/gists{/gist_id}", "starred_url": "https://api.github.com/users/keiranjprice101/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/keiranjprice101/subscriptions", "organizations_url": "https://api.github.com/users/keiranjprice101/orgs", "repos_url": "https://api.github.com/users/keiranjprice101/repos", "events_url": "https://api.github.com/users/keiranjprice101/events{/privacy}", "received_events_url": "https://api.github.com/users/keiranjprice101/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "The docs do make mention of this, there is in fact a section on this: http://docs.peewee-orm.com/en/latest/peewee/models.html#manually-specifying-primary-keys\r\n\r\nAt the most basic, though, this is all you need to add if you are doing this one-off:\r\n\r\n```\r\ncustomer.id = 4\r\ncustomer.email = \"example@example.com\"\r\ncustomer.save(force_insert=True)\r\n```" ]
"2023-05-01T12:02:11"
"2023-05-01T13:07:19"
"2023-05-01T13:07:18"
NONE
null
In this example: ```python class CustomerPeewee(BaseModel): email = CharField() class Meta: db_table = "customer" customer = CustomerPeewee() customer.id = 4 customer.email = "example@example.com" customer.save() ``` No record is created and 0 is returned. If this is intended it feels counter intuitive as the docs seem to make no mention of this behaviour not being possible
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/2717/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/2717/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/2716
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/2716/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/2716/comments
https://api.github.com/repos/coleifer/peewee/issues/2716/events
https://github.com/coleifer/peewee/issues/2716
1,687,136,706
I_kwDOAA7yGM5kj6nC
2,716
Automatic Migrations Capability
{ "login": "anuran-roy", "id": 76481787, "node_id": "MDQ6VXNlcjc2NDgxNzg3", "avatar_url": "https://avatars.githubusercontent.com/u/76481787?v=4", "gravatar_id": "", "url": "https://api.github.com/users/anuran-roy", "html_url": "https://github.com/anuran-roy", "followers_url": "https://api.github.com/users/anuran-roy/followers", "following_url": "https://api.github.com/users/anuran-roy/following{/other_user}", "gists_url": "https://api.github.com/users/anuran-roy/gists{/gist_id}", "starred_url": "https://api.github.com/users/anuran-roy/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/anuran-roy/subscriptions", "organizations_url": "https://api.github.com/users/anuran-roy/orgs", "repos_url": "https://api.github.com/users/anuran-roy/repos", "events_url": "https://api.github.com/users/anuran-roy/events{/privacy}", "received_events_url": "https://api.github.com/users/anuran-roy/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ ">since I couldn't find any automated tool for migrations\r\n\r\nYou may not have looked very hard, there are several I'm aware of:\r\n\r\n* https://github.com/klen/peewee_migrate\r\n* https://github.com/aachurin/peewee_migrations\r\n* https://github.com/timster/peewee-moves\r\n\r\nI can't vouch for the fitness or suitability of any of the above, but they all seem to offer automatic migrations in some form.\r\n\r\n>why automated migrations haven't been added\r\n\r\nBecause I don't believe they actually save much time, and that writing an explicit migration using the migrator module is preferable. Not everyone agrees with me, hence the above list. I have no plans on integrating such functionality into peewee, however.", "I actually found only aachurin/peewee_migrations and it seems to be inactive, so I raised the issue. Thanks for the clarification! " ]
"2023-04-27T15:58:44"
"2023-04-27T16:35:29"
"2023-04-27T16:13:05"
NONE
null
Hey there! Anuran this side! I'm a long time fan of peewee, been using it for a quite a few projects - thanks for this awesome tool, really saves a lot of time for someone who uses Django as well! 🚀 Actually I was on the process of creating a custom script for automated migrations, since I couldn't find any automated tool for migrations, so I decided to create one. I was going through the codebase of peewee - it's pretty neat. I wonder why an automated migrations haven't been added yet, especially given that `playhouse.migrate` does exist. Can I go forward and develop an `AutoMigrator` object, that depends on the objects provided by `playhouse.migrate`?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/2716/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/2716/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/2715
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/2715/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/2715/comments
https://api.github.com/repos/coleifer/peewee/issues/2715/events
https://github.com/coleifer/peewee/issues/2715
1,685,261,994
I_kwDOAA7yGM5kcw6q
2,715
Postgres error : Driver not installed, using peewee,docker and fastapi
{ "login": "Master-Y0da", "id": 10148942, "node_id": "MDQ6VXNlcjEwMTQ4OTQy", "avatar_url": "https://avatars.githubusercontent.com/u/10148942?v=4", "gravatar_id": "", "url": "https://api.github.com/users/Master-Y0da", "html_url": "https://github.com/Master-Y0da", "followers_url": "https://api.github.com/users/Master-Y0da/followers", "following_url": "https://api.github.com/users/Master-Y0da/following{/other_user}", "gists_url": "https://api.github.com/users/Master-Y0da/gists{/gist_id}", "starred_url": "https://api.github.com/users/Master-Y0da/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/Master-Y0da/subscriptions", "organizations_url": "https://api.github.com/users/Master-Y0da/orgs", "repos_url": "https://api.github.com/users/Master-Y0da/repos", "events_url": "https://api.github.com/users/Master-Y0da/events{/privacy}", "received_events_url": "https://api.github.com/users/Master-Y0da/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Apparently you didn't install `psycopg2`, or for some reason Peewee is unable to import it. In your `main.py` try adding a line `import psycopg2 ; print(psycopg2)` - it should be easy to tell.", "I intalled pyscogp2 not psycopg2 , really bad one hahaha thank you!!", "You might've installed some malware or a miner, be careful, people typosquat pypi stuff." ]
"2023-04-26T15:33:40"
"2023-04-26T16:44:22"
"2023-04-26T15:51:31"
NONE
null
I have installed peewee 3.16.2 ,pyscopg2 66.0.2 and fastapi 0.95.1. I follow the steps in peewee docs about integrate fastapi apps, but showing up this error **peewee.ImproperlyConfigured: Postgres driver not installed!** This is my config file in fastapi: def init_db(): db = PostgresqlDatabase( 'atlas_repos', user='atlas', password='password', host='localhost', port=5432) return db this function is called from a main.py in fastapi where I have a db.connect() function Any help would be much apreciated.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/2715/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/2715/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/2714
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/2714/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/2714/comments
https://api.github.com/repos/coleifer/peewee/issues/2714/events
https://github.com/coleifer/peewee/issues/2714
1,681,779,813
I_kwDOAA7yGM5kPexl
2,714
`peewee` for WebAssembly (JupyterLite + XEUS-Python + emscripten-forge)
{ "login": "michaelweinold", "id": 23102087, "node_id": "MDQ6VXNlcjIzMTAyMDg3", "avatar_url": "https://avatars.githubusercontent.com/u/23102087?v=4", "gravatar_id": "", "url": "https://api.github.com/users/michaelweinold", "html_url": "https://github.com/michaelweinold", "followers_url": "https://api.github.com/users/michaelweinold/followers", "following_url": "https://api.github.com/users/michaelweinold/following{/other_user}", "gists_url": "https://api.github.com/users/michaelweinold/gists{/gist_id}", "starred_url": "https://api.github.com/users/michaelweinold/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/michaelweinold/subscriptions", "organizations_url": "https://api.github.com/users/michaelweinold/orgs", "repos_url": "https://api.github.com/users/michaelweinold/repos", "events_url": "https://api.github.com/users/michaelweinold/events{/privacy}", "received_events_url": "https://api.github.com/users/michaelweinold/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "1. peewee does not necessarily require c extensions\r\n2. psycopg2cffi is only needed if you want to use postgres and is primarily aimed at pypy users who don't have c extensions, so I'm completely at a loss why this particular bit seemed so important to you.\r\n3. the error is not coming from peewee but seems related to however you're abstracting the file-system for use by sqlite. The error is coming from sqlite and seems to indicate some problem with the file." ]
"2023-04-24T18:06:14"
"2023-04-24T18:14:13"
"2023-04-24T18:14:12"
NONE
null
## Overview To bring the [Brightway life-cycle assessment python package](https://documentation.brightway.dev/) to the browser, [we](https://github.com/brightway-lca) recently added `peewee` to the WebAssembly [`emscripten-forge`](https://github.com/emscripten-forge/recipes) package repository. This was necessary since `peewee` comes with C extensions (more specifically, it is using [`psycopg2cffi`](https://github.com/coleifer/peewee/blob/c825a0fb11b1dae1f88d93c67f2fbcb4a34d4ad4/peewee.py#L43)). `emscripten-forge` is an alternative to the monolythic [Pyodide](https://pyodide.org/en/stable/index.html) Python WebAssembly distribution that is best described [in this article by the core development team.](https://blog.jupyter.org/mamba-meets-jupyterlite-88ef49ac4dc8) ## Error Unfortunately, I get an error when running it in a [JupyterLite](https://jupyterlite.readthedocs.io/en/latest/) XEUX-Python hub. While this is likely out-of-scope for the developers of `peewee`, I would be very grateful for any hints on the potential root cause. It might be realated to [the filesystem of JupyterLite](https://jupyterlite.readthedocs.io/en/latest/search.html?q=filesystem). ``` from peewee import * # Define a database object db = SqliteDatabase('my_database.db') # Define a model class class Person(Model): name = CharField() age = IntegerField() class Meta: database = db # Create the table in the database db.connect() db.create_tables([Person]) person1 = Person(name='Alice', age=25) person1.save() ``` returnes: ``` DatabaseError: database disk image is malformed ``` <details> <summary>Full Error Message</summary> ``` --------------------------------------------------------------------------- DatabaseError Traceback (most recent call last) /tmp/xeus-python-kernel/envs/xeus-python-kernel/lib/python3.10/site-packages/peewee.py in execute_sql(self, sql, params, commit) 3235 cursor = self.cursor() -> 3236 cursor.execute(sql, params or ()) 3237 return cursor DatabaseError: database disk image is malformed During handling of the above exception, another exception occurred: DatabaseError Traceback (most recent call last) /tmp/xpython_42/2390659374.py in <cell line: 2>() 1 person1 = Person(name='Alice', age=25) ----> 2 person1.save() /tmp/xeus-python-kernel/envs/xeus-python-kernel/lib/python3.10/site-packages/peewee.py in save(self, force_insert, only) 6745 rows = self.update(**field_dict).where(self._pk_expr()).execute() 6746 elif pk_field is not None: -> 6747 pk = self.insert(**field_dict).execute() 6748 if pk is not None and (self._meta.auto_increment or 6749 pk_value is None): /tmp/xeus-python-kernel/envs/xeus-python-kernel/lib/python3.10/site-packages/peewee.py in inner(self, database, *args, **kwargs) 1960 raise InterfaceError('Query must be bound to a database in order ' 1961 'to call "%s".' % method.__name__) -> 1962 return method(self, database, *args, **kwargs) 1963 return inner 1964 /tmp/xeus-python-kernel/envs/xeus-python-kernel/lib/python3.10/site-packages/peewee.py in execute(self, database) 2031 @database_required 2032 def execute(self, database): -> 2033 return self._execute(database) 2034 2035 def _execute(self, database): /tmp/xeus-python-kernel/envs/xeus-python-kernel/lib/python3.10/site-packages/peewee.py in _execute(self, database) 2836 self._returning = (self.table._primary_key,) 2837 try: -> 2838 return super(Insert, self)._execute(database) 2839 except self.DefaultValuesException: 2840 pass /tmp/xeus-python-kernel/envs/xeus-python-kernel/lib/python3.10/site-packages/peewee.py in _execute(self, database) 2549 cursor = self.execute_returning(database) 2550 else: -> 2551 cursor = database.execute(self) 2552 return self.handle_result(database, cursor) 2553 /tmp/xeus-python-kernel/envs/xeus-python-kernel/lib/python3.10/site-packages/peewee.py in execute(self, query, commit, **context_options) 3242 ctx = self.get_sql_context(**context_options) 3243 sql, params = ctx.sql(query).query() -> 3244 return self.execute_sql(sql, params) 3245 3246 def get_context_options(self): /tmp/xeus-python-kernel/envs/xeus-python-kernel/lib/python3.10/site-packages/peewee.py in execute_sql(self, sql, params, commit) 3232 __deprecated__('"commit" has been deprecated and is a no-op.') 3233 logger.debug((sql, params)) -> 3234 with __exception_wrapper__: 3235 cursor = self.cursor() 3236 cursor.execute(sql, params or ()) /tmp/xeus-python-kernel/envs/xeus-python-kernel/lib/python3.10/site-packages/peewee.py in __exit__(self, exc_type, exc_value, traceback) 3008 new_type = self.exceptions[exc_type.__name__] 3009 exc_args = exc_value.args -> 3010 reraise(new_type, new_type(exc_value, *exc_args), traceback) 3011 3012 /tmp/xeus-python-kernel/envs/xeus-python-kernel/lib/python3.10/site-packages/peewee.py in reraise(tp, value, tb) 190 def reraise(tp, value, tb=None): 191 if value.__traceback__ is not tb: --> 192 raise value.with_traceback(tb) 193 raise value 194 /tmp/xeus-python-kernel/envs/xeus-python-kernel/lib/python3.10/site-packages/peewee.py in execute_sql(self, sql, params, commit) 3234 with __exception_wrapper__: 3235 cursor = self.cursor() -> 3236 cursor.execute(sql, params or ()) 3237 return cursor 3238 DatabaseError: database disk image is malformed ``` </details> ## Reproduce Error Access the JupyterLite Hub and open `peewee_test.ipynb` at https://michaelweinold.github.io/hub/ ## Related - https://github.com/emscripten-forge/recipes/issues/295 - https://github.com/emscripten-forge/recipes/pull/322
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/2714/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/2714/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/2713
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/2713/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/2713/comments
https://api.github.com/repos/coleifer/peewee/issues/2713/events
https://github.com/coleifer/peewee/issues/2713
1,680,911,617
I_kwDOAA7yGM5kMK0B
2,713
How to "NOT" create index on a "unique" field
{ "login": "eddysnjack", "id": 38407276, "node_id": "MDQ6VXNlcjM4NDA3Mjc2", "avatar_url": "https://avatars.githubusercontent.com/u/38407276?v=4", "gravatar_id": "", "url": "https://api.github.com/users/eddysnjack", "html_url": "https://github.com/eddysnjack", "followers_url": "https://api.github.com/users/eddysnjack/followers", "following_url": "https://api.github.com/users/eddysnjack/following{/other_user}", "gists_url": "https://api.github.com/users/eddysnjack/gists{/gist_id}", "starred_url": "https://api.github.com/users/eddysnjack/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/eddysnjack/subscriptions", "organizations_url": "https://api.github.com/users/eddysnjack/orgs", "repos_url": "https://api.github.com/users/eddysnjack/repos", "events_url": "https://api.github.com/users/eddysnjack/events{/privacy}", "received_events_url": "https://api.github.com/users/eddysnjack/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "What database engine are you using?", "> What database engine are you using?\r\n\r\nhow can i check that?", "You presumably declared it yourself... SqliteDatabase, MySQLDatabase, PostgresqlDatabase...", "At any rate it seems to be working fine for me:\r\n\r\n```python\r\ndb = SqliteDatabase(':memory:')\r\n\r\nclass User(db.Model):\r\n username = TextField(null=True, unique=True)\r\n\r\nUser.create_table()\r\n\r\nUser.create(username=None)\r\nUser.create(username=None)\r\nUser.create(username='u1')\r\ntry:\r\n User.create(username='u1')\r\nexcept IntegrityError:\r\n pass\r\nelse:\r\n assert False, 'expected integrity error not raised'\r\n\r\nfor u in User:\r\n print(u.username)\r\n```\r\n\r\nCorrectly prints out:\r\n\r\n```\r\nNone\r\nNone\r\nu1\r\n```", "> You presumably declared it yourself... SqliteDatabase, MySQLDatabase, PostgresqlDatabase...\r\n\r\noh i see SqliteDatabase in this case. i misinterpreted \"engine\", sorry :)" ]
"2023-04-24T10:09:35"
"2023-04-24T13:47:48"
"2023-04-24T12:42:17"
NONE
null
i have o model looking like this. ``` class User(BaseModel): id = BigIntegerField(unique=True) first_name = TextField() last_name = CharField(null=True) username = CharField(unique=True, null=True, index=False) phone = CharField(null=True) deleted = BooleanField(null=True) is_bot = BooleanField(null=True) bio = CharField(null=True) photo = TextField(null=True) roles = BigIntegerField() ``` After tables are created when i check db file with sqlstudio i saw "username" index on user table. I dont want this, it is unique but should be null as well. I'm getting "UNIQUE constraint failed: user.username" error when I try to update or create a user without a username second time. I believe that index is the cause. <img width="870" alt="Screen Shot 2023-04-24 at 13 03 17" src="https://user-images.githubusercontent.com/38407276/233966648-e8504dc1-a15d-4fc8-974e-ad0f4ae42bba.png">
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/2713/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/2713/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/2712
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/2712/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/2712/comments
https://api.github.com/repos/coleifer/peewee/issues/2712/events
https://github.com/coleifer/peewee/issues/2712
1,680,522,237
I_kwDOAA7yGM5kKrv9
2,712
insert_many method missing field values.
{ "login": "frelion", "id": 71957494, "node_id": "MDQ6VXNlcjcxOTU3NDk0", "avatar_url": "https://avatars.githubusercontent.com/u/71957494?v=4", "gravatar_id": "", "url": "https://api.github.com/users/frelion", "html_url": "https://github.com/frelion", "followers_url": "https://api.github.com/users/frelion/followers", "following_url": "https://api.github.com/users/frelion/following{/other_user}", "gists_url": "https://api.github.com/users/frelion/gists{/gist_id}", "starred_url": "https://api.github.com/users/frelion/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/frelion/subscriptions", "organizations_url": "https://api.github.com/users/frelion/orgs", "repos_url": "https://api.github.com/users/frelion/repos", "events_url": "https://api.github.com/users/frelion/events{/privacy}", "received_events_url": "https://api.github.com/users/frelion/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "http://docs.peewee-orm.com/en/latest/peewee/api.html?highlight=insert_many#Model.insert_many", "Looks to be working fine:\r\n\r\n```python\r\nclass Reg(db.Model):\r\n val = TextField(null=True)\r\n\r\nReg.create_table()\r\nReg.insert_many([{}, {'val': 'asdf'}], fields=[Reg.val]).execute()\r\nprint(list(Reg.select().tuples()))\r\n# [(1, None), (2, 'asdf')]\r\n```" ]
"2023-04-24T06:07:36"
"2023-04-24T12:37:00"
"2023-04-24T07:07:49"
NONE
null
peewee==3.16.0 Python 3.10.6 For the following code: ``` class TestModel(Model): class Meta: database = mysql_db test_field = CharField(null=True) TestModel.create_table() insert_data = [ {}, { 'test_field': "hello" } ] TestModel.insert_many(insert_data).execute() ``` Result: ``` id test_field 1 NULL 2 NULL ``` The test_field field of the second record was not inserted. The following is the modified code: ``` class TestModel(Model): class Meta: database = mysql_db test_field = CharField(null=True) TestModel.create_table() insert_data = [{ 'test_field': None },{ 'test_field': "hello" } ] TestModel.insert_many(insert_data).execute() ``` It worked ``` id test_field 1 NULL 2 hello ``` Is it by design? This goes against my instincts. Thank you for working on such an easy-to-use ORM framework
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/2712/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/2712/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/2711
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/2711/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/2711/comments
https://api.github.com/repos/coleifer/peewee/issues/2711/events
https://github.com/coleifer/peewee/pull/2711
1,676,462,240
PR_kwDOAA7yGM5OwRRM
2,711
Feature/filter none on where
{ "login": "ponponon", "id": 38725104, "node_id": "MDQ6VXNlcjM4NzI1MTA0", "avatar_url": "https://avatars.githubusercontent.com/u/38725104?v=4", "gravatar_id": "", "url": "https://api.github.com/users/ponponon", "html_url": "https://github.com/ponponon", "followers_url": "https://api.github.com/users/ponponon/followers", "following_url": "https://api.github.com/users/ponponon/following{/other_user}", "gists_url": "https://api.github.com/users/ponponon/gists{/gist_id}", "starred_url": "https://api.github.com/users/ponponon/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/ponponon/subscriptions", "organizations_url": "https://api.github.com/users/ponponon/orgs", "repos_url": "https://api.github.com/users/ponponon/repos", "events_url": "https://api.github.com/users/ponponon/events{/privacy}", "received_events_url": "https://api.github.com/users/ponponon/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "I don't think silently ignoring arguments is a good plan, the issue is the caller passing `None` in the first place." ]
"2023-04-20T10:35:57"
"2023-04-20T12:33:25"
"2023-04-20T12:33:25"
NONE
null
```python q = SeriesTable.select().where( None, None ) ``` If where is called for the first time and where has more than one None parameter, an error will occur: ```shell Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/Users/ponponon/Desktop/code/me/gs_review_api/dev/peewee_in.py", line 32, in <module> q = SeriesTable.select().where( ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/ponponon/.local/share/virtualenvs/gs_review_api-0lO5qGKr/lib/python3.11/site-packages/peewee.py", line 755, in inner method(clone, *args, **kwargs) File "/Users/ponponon/.local/share/virtualenvs/gs_review_api-0lO5qGKr/lib/python3.11/site-packages/peewee.py", line 2156, in where self._where = reduce(operator.and_, expressions) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: unsupported operand type(s) for &: 'NoneType' and 'NoneType' ``` So we filter the parameters of where and ignore those with the value None to avoid errors
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/2711/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/2711/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/2711", "html_url": "https://github.com/coleifer/peewee/pull/2711", "diff_url": "https://github.com/coleifer/peewee/pull/2711.diff", "patch_url": "https://github.com/coleifer/peewee/pull/2711.patch", "merged_at": null }
https://api.github.com/repos/coleifer/peewee/issues/2710
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/2710/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/2710/comments
https://api.github.com/repos/coleifer/peewee/issues/2710/events
https://github.com/coleifer/peewee/pull/2710
1,676,397,519
PR_kwDOAA7yGM5OwDKO
2,710
feature: When `.in_(None)` is executed, the null condition should be …
{ "login": "ponponon", "id": 38725104, "node_id": "MDQ6VXNlcjM4NzI1MTA0", "avatar_url": "https://avatars.githubusercontent.com/u/38725104?v=4", "gravatar_id": "", "url": "https://api.github.com/users/ponponon", "html_url": "https://github.com/ponponon", "followers_url": "https://api.github.com/users/ponponon/followers", "following_url": "https://api.github.com/users/ponponon/following{/other_user}", "gists_url": "https://api.github.com/users/ponponon/gists{/gist_id}", "starred_url": "https://api.github.com/users/ponponon/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/ponponon/subscriptions", "organizations_url": "https://api.github.com/users/ponponon/orgs", "repos_url": "https://api.github.com/users/ponponon/repos", "events_url": "https://api.github.com/users/ponponon/events{/privacy}", "received_events_url": "https://api.github.com/users/ponponon/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "No, I think `.in_(None)` is incorrect since `None` is not an iterable - going to pass on this." ]
"2023-04-20T09:55:00"
"2023-04-20T12:32:35"
"2023-04-20T12:32:35"
NONE
null
When `.in_(None)` is executed, the null condition should be ignored as `0 = 1`
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/2710/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/2710/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/2710", "html_url": "https://github.com/coleifer/peewee/pull/2710", "diff_url": "https://github.com/coleifer/peewee/pull/2710.diff", "patch_url": "https://github.com/coleifer/peewee/pull/2710.patch", "merged_at": null }
https://api.github.com/repos/coleifer/peewee/issues/2709
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/2709/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/2709/comments
https://api.github.com/repos/coleifer/peewee/issues/2709/events
https://github.com/coleifer/peewee/issues/2709
1,674,699,657
I_kwDOAA7yGM5j0eOJ
2,709
db.atomic decorator is not a thread-safe
{ "login": "delatars", "id": 22956479, "node_id": "MDQ6VXNlcjIyOTU2NDc5", "avatar_url": "https://avatars.githubusercontent.com/u/22956479?v=4", "gravatar_id": "", "url": "https://api.github.com/users/delatars", "html_url": "https://github.com/delatars", "followers_url": "https://api.github.com/users/delatars/followers", "following_url": "https://api.github.com/users/delatars/following{/other_user}", "gists_url": "https://api.github.com/users/delatars/gists{/gist_id}", "starred_url": "https://api.github.com/users/delatars/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/delatars/subscriptions", "organizations_url": "https://api.github.com/users/delatars/orgs", "repos_url": "https://api.github.com/users/delatars/repos", "events_url": "https://api.github.com/users/delatars/events{/privacy}", "received_events_url": "https://api.github.com/users/delatars/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Yes you're quite right, thanks for finding this. The issue is down to the fact that a single instance is being created and reused/overwritten. I will figure out a fix. For now the workaround will need to be to use the context manager.", "This should now be fixed.", "3.16.2 release contains this fix, thanks for the report this really needed to be fixed!" ]
"2023-04-19T11:19:19"
"2023-04-21T20:18:44"
"2023-04-19T13:11:14"
NONE
null
Hello! peewee: 3.15.4 python: 3.10.8 Using db.atomic as decorator is not a thread-safe. The following example is showing that behaviour. ```python import logging import random import uuid from concurrent.futures import ThreadPoolExecutor from time import sleep import peewee from playhouse.pool import PooledPostgresqlExtDatabase db = PooledPostgresqlExtDatabase( database='test', user='postgres', password='postgres', host='localhost', ) logging.basicConfig( level=logging.DEBUG, format='[%(asctime)s] %(levelname)s [%(thread)s] %(message)s', datefmt='%Y-%m-%d %H:%M:%S', ) class User(peewee.Model): class Meta: database = db table_name = 'users' name = peewee.TextField() @db.atomic() def get_first(): sleep(random.randint(1, 3)) return User.select().first() def main(n): print(f'task {n}: start') with db.atomic(): User.insert(name=uuid.uuid4().hex).execute() get_first() with ThreadPoolExecutor(max_workers=5) as worker: worker.map(main, range(5)) ``` app logs ``` [2023-04-19 13:59:56] DEBUG [6174699520] No connection available in pool. [2023-04-19 13:59:56] DEBUG [6174699520] Created new connection 4365525936. [2023-04-19 13:59:56] DEBUG [6174699520] ('INSERT INTO "users" ("name") VALUES (%s) RETURNING "users"."id"', ['erika16']) [2023-04-19 13:59:56] DEBUG [6191525888] No connection available in pool. [2023-04-19 13:59:56] DEBUG [6191525888] Created new connection 4365526608. [2023-04-19 13:59:56] DEBUG [6191525888] ('INSERT INTO "users" ("name") VALUES (%s) RETURNING "users"."id"', ['qfritz']) [2023-04-19 13:59:56] DEBUG [6208352256] No connection available in pool. [2023-04-19 13:59:56] DEBUG [6174699520] ('SAVEPOINT "s36f6b1b9c9964d338b76086917abfa2c";', None) [2023-04-19 13:59:56] DEBUG [6191525888] ('SAVEPOINT "sf48e71a842874f81989e4b29ebb93c5b";', None) [2023-04-19 13:59:56] DEBUG [6208352256] Created new connection 4365526944. [2023-04-19 13:59:56] DEBUG [6208352256] ('INSERT INTO "users" ("name") VALUES (%s) RETURNING "users"."id"', ['paulanderson']) [2023-04-19 13:59:56] DEBUG [6225178624] No connection available in pool. [2023-04-19 13:59:56] DEBUG [6225178624] Created new connection 4365527280. [2023-04-19 13:59:56] DEBUG [6225178624] ('INSERT INTO "users" ("name") VALUES (%s) RETURNING "users"."id"', ['patricia09']) [2023-04-19 13:59:56] DEBUG [6242004992] No connection available in pool. [2023-04-19 13:59:56] DEBUG [6225178624] ('SAVEPOINT "s4ce9c8529df342a9ac71c47196be2567";', None) [2023-04-19 13:59:56] DEBUG [6242004992] Created new connection 4365527616. [2023-04-19 13:59:56] DEBUG [6242004992] ('INSERT INTO "users" ("name") VALUES (%s) RETURNING "users"."id"', ['christina08']) [2023-04-19 13:59:57] DEBUG [6208352256] ('SAVEPOINT "s33981849fd6345f69f7365c8279e4472";', None) [2023-04-19 13:59:57] DEBUG [6242004992] ('SAVEPOINT "s97756b77a9264a9cbf194afde4f9e546";', None) [2023-04-19 13:59:57] DEBUG [6174699520] ('SELECT "t1"."id", "t1"."name" FROM "users" AS "t1" LIMIT %s', [1]) [2023-04-19 13:59:57] DEBUG [6174699520] ('RELEASE SAVEPOINT "s97756b77a9264a9cbf194afde4f9e546";', None) [2023-04-19 13:59:57] DEBUG [6174699520] ('ROLLBACK TO SAVEPOINT "s97756b77a9264a9cbf194afde4f9e546";', None) [2023-04-19 13:59:57] DEBUG [6191525888] ('SELECT "t1"."id", "t1"."name" FROM "users" AS "t1" LIMIT %s', [1]) [2023-04-19 13:59:57] DEBUG [6191525888] ('RELEASE SAVEPOINT "s97756b77a9264a9cbf194afde4f9e546";', None) [2023-04-19 13:59:57] DEBUG [6191525888] ('ROLLBACK TO SAVEPOINT "s97756b77a9264a9cbf194afde4f9e546";', None) [2023-04-19 13:59:58] DEBUG [6208352256] ('SELECT "t1"."id", "t1"."name" FROM "users" AS "t1" LIMIT %s', [1]) [2023-04-19 13:59:58] DEBUG [6208352256] ('RELEASE SAVEPOINT "s97756b77a9264a9cbf194afde4f9e546";', None) [2023-04-19 13:59:58] DEBUG [6208352256] ('ROLLBACK TO SAVEPOINT "s97756b77a9264a9cbf194afde4f9e546";', None) [2023-04-19 13:59:58] DEBUG [6242004992] ('SELECT "t1"."id", "t1"."name" FROM "users" AS "t1" LIMIT %s', [1]) [2023-04-19 13:59:58] DEBUG [6242004992] ('RELEASE SAVEPOINT "s97756b77a9264a9cbf194afde4f9e546";', None) [2023-04-19 13:59:59] DEBUG [6225178624] ('SELECT "t1"."id", "t1"."name" FROM "users" AS "t1" LIMIT %s', [1]) [2023-04-19 13:59:59] DEBUG [6225178624] ('RELEASE SAVEPOINT "s97756b77a9264a9cbf194afde4f9e546";', None) [2023-04-19 13:59:59] DEBUG [6225178624] ('ROLLBACK TO SAVEPOINT "s97756b77a9264a9cbf194afde4f9e546";', None) ``` In the logs above, we're see, that threads are trying to release savepoint with an id it did not create. postgres logs: ``` 2023-04-19 10:59:56.522 UTC [61057] LOG: statement: BEGIN 2023-04-19 10:59:56.543 UTC [61057] LOG: duration: 23.928 ms 2023-04-19 10:59:56.549 UTC [61057] LOG: statement: INSERT INTO "users" ("name") VALUES ('erika16') RETURNING "users"."id" 2023-04-19 10:59:56.615 UTC [61057] LOG: duration: 68.462 ms 2023-04-19 10:59:56.626 UTC [61059] LOG: statement: BEGIN 2023-04-19 10:59:56.630 UTC [61059] LOG: duration: 6.580 ms 2023-04-19 10:59:56.636 UTC [61059] LOG: statement: INSERT INTO "users" ("name") VALUES ('qfritz') RETURNING "users"."id" 2023-04-19 10:59:56.637 UTC [61057] LOG: statement: SAVEPOINT "s36f6b1b9c9964d338b76086917abfa2c"; 2023-04-19 10:59:56.637 UTC [61057] LOG: duration: 0.593 ms 2023-04-19 10:59:56.678 UTC [61059] LOG: duration: 42.479 ms 2023-04-19 10:59:56.689 UTC [61059] LOG: statement: SAVEPOINT "sf48e71a842874f81989e4b29ebb93c5b"; 2023-04-19 10:59:56.691 UTC [61059] LOG: duration: 1.423 ms 2023-04-19 10:59:56.728 UTC [61061] LOG: statement: BEGIN 2023-04-19 10:59:56.732 UTC [61061] LOG: duration: 8.113 ms 2023-04-19 10:59:56.735 UTC [61061] LOG: statement: INSERT INTO "users" ("name") VALUES ('paulanderson') RETURNING "users"."id" 2023-04-19 10:59:56.819 UTC [61063] LOG: statement: BEGIN 2023-04-19 10:59:56.824 UTC [61063] LOG: duration: 6.820 ms 2023-04-19 10:59:56.828 UTC [61063] LOG: statement: INSERT INTO "users" ("name") VALUES ('patricia09') RETURNING "users"."id" 2023-04-19 10:59:56.922 UTC [61063] LOG: duration: 94.511 ms 2023-04-19 10:59:56.928 UTC [61063] LOG: statement: SAVEPOINT "s4ce9c8529df342a9ac71c47196be2567"; 2023-04-19 10:59:56.929 UTC [61063] LOG: duration: 0.893 ms 2023-04-19 10:59:56.981 UTC [61065] LOG: statement: BEGIN 2023-04-19 10:59:56.984 UTC [61065] LOG: duration: 5.307 ms 2023-04-19 10:59:56.987 UTC [61065] LOG: statement: INSERT INTO "users" ("name") VALUES ('christina08') RETURNING "users"."id" 2023-04-19 10:59:57.009 UTC [61061] LOG: duration: 274.434 ms 2023-04-19 10:59:57.015 UTC [61061] LOG: statement: SAVEPOINT "s33981849fd6345f69f7365c8279e4472"; 2023-04-19 10:59:57.015 UTC [61061] LOG: duration: 0.838 ms 2023-04-19 10:59:57.219 UTC [61065] LOG: duration: 232.845 ms 2023-04-19 10:59:57.222 UTC [61065] LOG: statement: SAVEPOINT "s97756b77a9264a9cbf194afde4f9e546"; 2023-04-19 10:59:57.222 UTC [61065] LOG: duration: 0.481 ms 2023-04-19 10:59:57.644 UTC [61057] LOG: statement: SELECT "t1"."id", "t1"."name" FROM "users" AS "t1" LIMIT 1 2023-04-19 10:59:57.657 UTC [61057] LOG: duration: 13.231 ms 2023-04-19 10:59:57.661 UTC [61057] LOG: statement: RELEASE SAVEPOINT "s97756b77a9264a9cbf194afde4f9e546"; 2023-04-19 10:59:57.662 UTC [61057] ERROR: savepoint "s97756b77a9264a9cbf194afde4f9e546" does not exist 2023-04-19 10:59:57.662 UTC [61057] STATEMENT: RELEASE SAVEPOINT "s97756b77a9264a9cbf194afde4f9e546"; 2023-04-19 10:59:57.672 UTC [61057] LOG: statement: ROLLBACK TO SAVEPOINT "s97756b77a9264a9cbf194afde4f9e546"; 2023-04-19 10:59:57.673 UTC [61057] ERROR: savepoint "s97756b77a9264a9cbf194afde4f9e546" does not exist 2023-04-19 10:59:57.673 UTC [61057] STATEMENT: ROLLBACK TO SAVEPOINT "s97756b77a9264a9cbf194afde4f9e546"; 2023-04-19 10:59:57.677 UTC [61057] LOG: statement: ROLLBACK 2023-04-19 10:59:57.684 UTC [61057] LOG: duration: 6.259 ms 2023-04-19 10:59:57.695 UTC [61059] LOG: statement: SELECT "t1"."id", "t1"."name" FROM "users" AS "t1" LIMIT 1 2023-04-19 10:59:57.721 UTC [61059] LOG: duration: 26.199 ms 2023-04-19 10:59:57.724 UTC [61059] LOG: statement: RELEASE SAVEPOINT "s97756b77a9264a9cbf194afde4f9e546"; 2023-04-19 10:59:57.726 UTC [61059] ERROR: savepoint "s97756b77a9264a9cbf194afde4f9e546" does not exist 2023-04-19 10:59:57.726 UTC [61059] STATEMENT: RELEASE SAVEPOINT "s97756b77a9264a9cbf194afde4f9e546"; 2023-04-19 10:59:57.733 UTC [61059] LOG: statement: ROLLBACK TO SAVEPOINT "s97756b77a9264a9cbf194afde4f9e546"; 2023-04-19 10:59:57.734 UTC [61059] ERROR: savepoint "s97756b77a9264a9cbf194afde4f9e546" does not exist 2023-04-19 10:59:57.734 UTC [61059] STATEMENT: ROLLBACK TO SAVEPOINT "s97756b77a9264a9cbf194afde4f9e546"; 2023-04-19 10:59:57.741 UTC [61059] LOG: statement: ROLLBACK 2023-04-19 10:59:57.778 UTC [61059] LOG: duration: 37.320 ms 2023-04-19 10:59:58.023 UTC [61061] LOG: statement: SELECT "t1"."id", "t1"."name" FROM "users" AS "t1" LIMIT 1 2023-04-19 10:59:58.041 UTC [61061] LOG: duration: 18.985 ms 2023-04-19 10:59:58.045 UTC [61061] LOG: statement: RELEASE SAVEPOINT "s97756b77a9264a9cbf194afde4f9e546"; 2023-04-19 10:59:58.046 UTC [61061] ERROR: savepoint "s97756b77a9264a9cbf194afde4f9e546" does not exist 2023-04-19 10:59:58.046 UTC [61061] STATEMENT: RELEASE SAVEPOINT "s97756b77a9264a9cbf194afde4f9e546"; 2023-04-19 10:59:58.050 UTC [61061] LOG: statement: ROLLBACK TO SAVEPOINT "s97756b77a9264a9cbf194afde4f9e546"; 2023-04-19 10:59:58.051 UTC [61061] ERROR: savepoint "s97756b77a9264a9cbf194afde4f9e546" does not exist 2023-04-19 10:59:58.051 UTC [61061] STATEMENT: ROLLBACK TO SAVEPOINT "s97756b77a9264a9cbf194afde4f9e546"; 2023-04-19 10:59:58.054 UTC [61061] LOG: statement: ROLLBACK 2023-04-19 10:59:58.071 UTC [61061] LOG: duration: 17.898 ms 2023-04-19 10:59:58.228 UTC [61065] LOG: statement: SELECT "t1"."id", "t1"."name" FROM "users" AS "t1" LIMIT 1 2023-04-19 10:59:58.247 UTC [61065] LOG: duration: 20.065 ms 2023-04-19 10:59:58.249 UTC [61065] LOG: statement: RELEASE SAVEPOINT "s97756b77a9264a9cbf194afde4f9e546"; 2023-04-19 10:59:58.250 UTC [61065] LOG: duration: 1.504 ms 2023-04-19 10:59:58.251 UTC [61065] LOG: statement: COMMIT 2023-04-19 10:59:58.254 UTC [61065] LOG: duration: 2.655 ms 2023-04-19 10:59:59.937 UTC [61063] LOG: statement: SELECT "t1"."id", "t1"."name" FROM "users" AS "t1" LIMIT 1 2023-04-19 10:59:59.957 UTC [61063] LOG: duration: 20.771 ms 2023-04-19 10:59:59.960 UTC [61063] LOG: statement: RELEASE SAVEPOINT "s97756b77a9264a9cbf194afde4f9e546"; 2023-04-19 10:59:59.961 UTC [61063] ERROR: savepoint "s97756b77a9264a9cbf194afde4f9e546" does not exist 2023-04-19 10:59:59.961 UTC [61063] STATEMENT: RELEASE SAVEPOINT "s97756b77a9264a9cbf194afde4f9e546"; 2023-04-19 10:59:59.964 UTC [61063] LOG: statement: ROLLBACK TO SAVEPOINT "s97756b77a9264a9cbf194afde4f9e546"; 2023-04-19 10:59:59.964 UTC [61063] ERROR: savepoint "s97756b77a9264a9cbf194afde4f9e546" does not exist 2023-04-19 10:59:59.964 UTC [61063] STATEMENT: ROLLBACK TO SAVEPOINT "s97756b77a9264a9cbf194afde4f9e546"; 2023-04-19 10:59:59.966 UTC [61063] LOG: statement: ROLLBACK 2023-04-19 10:59:59.968 UTC [61063] LOG: duration: 1.987 ms ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/2709/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/2709/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/2708
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/2708/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/2708/comments
https://api.github.com/repos/coleifer/peewee/issues/2708/events
https://github.com/coleifer/peewee/pull/2708
1,667,423,731
PR_kwDOAA7yGM5OSM0H
2,708
update pwiz add fields attr
{ "login": "GuoGuo54", "id": 38908865, "node_id": "MDQ6VXNlcjM4OTA4ODY1", "avatar_url": "https://avatars.githubusercontent.com/u/38908865?v=4", "gravatar_id": "", "url": "https://api.github.com/users/GuoGuo54", "html_url": "https://github.com/GuoGuo54", "followers_url": "https://api.github.com/users/GuoGuo54/followers", "following_url": "https://api.github.com/users/GuoGuo54/following{/other_user}", "gists_url": "https://api.github.com/users/GuoGuo54/gists{/gist_id}", "starred_url": "https://api.github.com/users/GuoGuo54/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/GuoGuo54/subscriptions", "organizations_url": "https://api.github.com/users/GuoGuo54/orgs", "repos_url": "https://api.github.com/users/GuoGuo54/repos", "events_url": "https://api.github.com/users/GuoGuo54/events{/privacy}", "received_events_url": "https://api.github.com/users/GuoGuo54/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Going to pass. `column_comment` isn't supported by postgres, btw." ]
"2023-04-14T02:47:10"
"2023-04-14T14:09:35"
"2023-04-14T14:09:34"
NONE
null
Issues #2707 : https://github.com/coleifer/peewee/issues
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/2708/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/2708/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/2708", "html_url": "https://github.com/coleifer/peewee/pull/2708", "diff_url": "https://github.com/coleifer/peewee/pull/2708.diff", "patch_url": "https://github.com/coleifer/peewee/pull/2708.patch", "merged_at": null }
https://api.github.com/repos/coleifer/peewee/issues/2707
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/2707/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/2707/comments
https://api.github.com/repos/coleifer/peewee/issues/2707/events
https://github.com/coleifer/peewee/issues/2707
1,667,373,094
I_kwDOAA7yGM5jYhgm
2,707
pwiz generates detailed field attributes
{ "login": "GuoGuo54", "id": 38908865, "node_id": "MDQ6VXNlcjM4OTA4ODY1", "avatar_url": "https://avatars.githubusercontent.com/u/38908865?v=4", "gravatar_id": "", "url": "https://api.github.com/users/GuoGuo54", "html_url": "https://github.com/GuoGuo54", "followers_url": "https://api.github.com/users/GuoGuo54/followers", "following_url": "https://api.github.com/users/GuoGuo54/following{/other_user}", "gists_url": "https://api.github.com/users/GuoGuo54/gists{/gist_id}", "starred_url": "https://api.github.com/users/GuoGuo54/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/GuoGuo54/subscriptions", "organizations_url": "https://api.github.com/users/GuoGuo54/orgs", "repos_url": "https://api.github.com/users/GuoGuo54/repos", "events_url": "https://api.github.com/users/GuoGuo54/events{/privacy}", "received_events_url": "https://api.github.com/users/GuoGuo54/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Going to pass. Column comments is mysql-specific, and the varchar max length is negligible in my view, since adding it to the introspected field doesn't change any behavior (and it usually isn't enforced anywhere)." ]
"2023-04-14T01:32:46"
"2023-04-14T14:11:37"
"2023-04-14T14:11:37"
NONE
null
The peewee model generated by pwiz based on the database table is too simple, like: class NameModel(Model): name = CharField(null=True) status = IntegerField(default=11, index=True) class Meta: table_name = 'name_model' But generally we need more detailed field attributes,like (max_length, verbose): class NameModel(Model): name = CharField(max_length=128, null=True, verbose_name='name') status = IntegerField(default=11, index=True, verbose_name='status') class Meta: table_name = 'name_model'
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/2707/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/2707/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/2706
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/2706/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/2706/comments
https://api.github.com/repos/coleifer/peewee/issues/2706/events
https://github.com/coleifer/peewee/issues/2706
1,666,749,628
I_kwDOAA7yGM5jWJS8
2,706
How to avoid fetch-then-create pattern, when fk id already known?
{ "login": "anentropic", "id": 147840, "node_id": "MDQ6VXNlcjE0Nzg0MA==", "avatar_url": "https://avatars.githubusercontent.com/u/147840?v=4", "gravatar_id": "", "url": "https://api.github.com/users/anentropic", "html_url": "https://github.com/anentropic", "followers_url": "https://api.github.com/users/anentropic/followers", "following_url": "https://api.github.com/users/anentropic/following{/other_user}", "gists_url": "https://api.github.com/users/anentropic/gists{/gist_id}", "starred_url": "https://api.github.com/users/anentropic/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/anentropic/subscriptions", "organizations_url": "https://api.github.com/users/anentropic/orgs", "repos_url": "https://api.github.com/users/anentropic/repos", "events_url": "https://api.github.com/users/anentropic/events{/privacy}", "received_events_url": "https://api.github.com/users/anentropic/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "You can just do this:\r\n\r\n```\r\ngame = GameSession.create(user=user_id, subject=subject)\r\n```" ]
"2023-04-13T16:33:13"
"2023-04-13T16:37:19"
"2023-04-13T16:37:18"
NONE
null
New to Peewee... I'm sure this is easy but could not find an example in the docs In a case like this: ```python def start_game(user_id, subject: str) -> GameSession: user = User.get(User.id == user_id) game = GameSession.create(user=user, subject=subject) return game ``` How do I avoid first fetching the `User`, and instead create `GameSession` directly using the `user_id` already known for the foreign key field Is there something like Django's `user__id` relation-spanning syntax, or implicit `_id` suffixed fields for foreign keys?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/2706/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/2706/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/2705
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/2705/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/2705/comments
https://api.github.com/repos/coleifer/peewee/issues/2705/events
https://github.com/coleifer/peewee/issues/2705
1,663,812,893
I_kwDOAA7yGM5jK8Ud
2,705
Bitwise shift operators as functions?
{ "login": "andycasey", "id": 504436, "node_id": "MDQ6VXNlcjUwNDQzNg==", "avatar_url": "https://avatars.githubusercontent.com/u/504436?v=4", "gravatar_id": "", "url": "https://api.github.com/users/andycasey", "html_url": "https://github.com/andycasey", "followers_url": "https://api.github.com/users/andycasey/followers", "following_url": "https://api.github.com/users/andycasey/following{/other_user}", "gists_url": "https://api.github.com/users/andycasey/gists{/gist_id}", "starred_url": "https://api.github.com/users/andycasey/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/andycasey/subscriptions", "organizations_url": "https://api.github.com/users/andycasey/orgs", "repos_url": "https://api.github.com/users/andycasey/repos", "events_url": "https://api.github.com/users/andycasey/events{/privacy}", "received_events_url": "https://api.github.com/users/andycasey/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "You can look at how the `bin_and()`, `bin_or()`, and `__xor__()` methods on field/columns are implemented. There are no bitwish shifts at present, but it should be easy to add them for your case. You can do this as a standalone function, e.g.\r\n\r\n```python\r\ndef lshift(lhs, rhs):\r\n return Expression(lhs, '<<', rhs)\r\n\r\n# Usage.\r\nfn.div(cf, 8).cast('integer') ^ lshift(1, fn.mod(cf, 8).cast('integer'))\r\n```\r\n\r\nMinimal example:\r\n\r\n```python\r\nclass Reg(db.Model):\r\n value = IntegerField()\r\n\r\ndb.create_tables([Reg])\r\n\r\ndef lshift(lhs, rhs):\r\n return Expression(lhs, '<<', rhs)\r\n\r\nfor i in range(10):\r\n Reg.create(value=i)\r\n\r\nquery = Reg.select(Reg.value, lshift(Reg.value, 2).alias('shifted'))\r\nfor row in query:\r\n print(row.value, row.shifted)\r\n\r\n# 0 0\r\n# 1 4\r\n# 2 8\r\n# 3 12\r\n# 4 16\r\n# ...\r\n```" ]
"2023-04-12T05:22:22"
"2023-04-12T13:04:38"
"2023-04-12T13:04:37"
NONE
null
Hi, I know the Python operators `<<` and `>>` are overloaded in `peewee`. I'm wondering if there is some function (in `peewee.fn`) to use the [bitwise shift left/right operators in Postgresql](https://www.postgresql.org/docs/current/functions-bitstring.html). I've searched a lot but can't find anything myself. My use case is that I am doing a bitwise OR operation on a byte from a bytearray like this: ```python class Source(BaseModel): carton_flags = BigBitField() # search by a carton flag `cf` ... where=( fn.get_byte(self.carton_flags, fn.div(cf, 8).cast("integer")) ^ (1 << fn.mod(cf, 8).cast("integer")) ) ``` And I'm running into Python errors (`TypeError: unsupported operand type(s) for <<: 'int' and 'Cast'`), which forced me to use some ugly-ass `SQL()` unless I could find the bitwise left/right functions. Right now my workaround solution is to use ```python where=(fn.get_bit(self.carton_flags, cf) != 0) ``` but I'm wondering if there the bitwise left/right shift functions have been interfaced somewhere. Thanks
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/2705/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/2705/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/2704
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/2704/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/2704/comments
https://api.github.com/repos/coleifer/peewee/issues/2704/events
https://github.com/coleifer/peewee/issues/2704
1,661,731,988
I_kwDOAA7yGM5jDASU
2,704
get_or_none() fails with postgres
{ "login": "TxMat", "id": 46858765, "node_id": "MDQ6VXNlcjQ2ODU4NzY1", "avatar_url": "https://avatars.githubusercontent.com/u/46858765?v=4", "gravatar_id": "", "url": "https://api.github.com/users/TxMat", "html_url": "https://github.com/TxMat", "followers_url": "https://api.github.com/users/TxMat/followers", "following_url": "https://api.github.com/users/TxMat/following{/other_user}", "gists_url": "https://api.github.com/users/TxMat/gists{/gist_id}", "starred_url": "https://api.github.com/users/TxMat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/TxMat/subscriptions", "organizations_url": "https://api.github.com/users/TxMat/orgs", "repos_url": "https://api.github.com/users/TxMat/repos", "events_url": "https://api.github.com/users/TxMat/events{/privacy}", "received_events_url": "https://api.github.com/users/TxMat/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "`get_or_none()` takes an expression. See docs: https://docs.peewee-orm.com/en/latest/peewee/api.html#Model.get_or_none\r\n\r\n```python\r\nShippingInfo.get_or_none(\r\n ShippingInfo.id == order.shipping_info)\r\n```\r\n\r\nA cursory look would have solved this for you.", "It indeed makes sense but for some reason the erroneous syntax Is totally valid when using an SQLite database witch threw me off a little bit." ]
"2023-04-11T04:01:29"
"2023-04-11T17:48:12"
"2023-04-11T11:55:38"
NONE
null
```py # Get shipping info from order.shipping_info_id shipping_info = {} if order.shipping_info: shipping_info = model_to_dict(ShippingInfo.get_or_none(order.shipping_info)) # no need to send id to client del shipping_info["id"] ``` Get_or_none with postgres raises `psycopg2.errors.DatatypeMismatch: argument of WHERE must be type boolean, not type integer` as the query built uses `WHERE 1` here is the full sql query : ``` SELECT "t1"."id", "t1"."country", "t1"."address", "t1"."postal_code", "t1"."city", "t1"."province" FROM "shippinginfo" AS "t1" WHERE 1 LIMIT 1 OFFSET 0' ``` I'm now using select and get as a temporary fix ```py # Get shipping info from order.shipping_info_id shipping_info = {} if order.shipping_info: shipping_info = model_to_dict(ShippingInfo.select().where(ShippingInfo.id == order.shipping_info.id).get()) # no need to send id to client del shipping_info["id" ``` Full stack trace : --- ``` functional_test.py:133 (TestPutShippingInfoOrder.test_put_order_valid_shipping_info) self = <peewee.PostgresqlDatabase object at 0x7f3d953e5a10> sql = 'SELECT "t1"."id", "t1"."country", "t1"."address", "t1"."postal_code", "t1"."city", "t1"."province" FROM "shippinginfo" AS "t1" WHERE %s LIMIT %s OFFSET %s' params = [1, 1, 0], commit = None def execute_sql(self, sql, params=None, commit=None): if commit is not None: __deprecated__('"commit" has been deprecated and is a no-op.') logger.debug((sql, params)) with __exception_wrapper__: cursor = self.cursor() > cursor.execute(sql, params or ()) E psycopg2.errors.DatatypeMismatch: argument of WHERE must be type boolean, not type integer E LINE 1: ..."t1"."province" FROM "shippinginfo" AS "t1" WHERE 1 LIMIT 1 ... E ^ ../../venv/lib/python3.11/site-packages/peewee.py:3236: DatatypeMismatch During handling of the above exception, another exception occurred: self = <Tests.functional_test.TestPutShippingInfoOrder object at 0x7f3d942c7310> client = <FlaskClient <Flask 'api.inf349'>> def test_put_order_valid_shipping_info(self, client): create_order(client) > response = client.put('/order/1', json={ "order": { "email": "elon.musk@spacex.com", "shipping_information": { "country": "Senegal", "address": "Rue des potiers", "postal_code": "G7H 0S5", "city": "Chicoutimi", "province": "QC" } } }) functional_test.py:136: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../../venv/lib/python3.11/site-packages/werkzeug/test.py:1151: in put return self.open(*args, **kw) ../../venv/lib/python3.11/site-packages/flask/testing.py:223: in open response = super().open( ../../venv/lib/python3.11/site-packages/werkzeug/test.py:1095: in open response = self.run_wsgi_app(request.environ, buffered=buffered) ../../venv/lib/python3.11/site-packages/werkzeug/test.py:962: in run_wsgi_app rv = run_wsgi_app(self.application, environ, buffered=buffered) ../../venv/lib/python3.11/site-packages/werkzeug/test.py:1243: in run_wsgi_app app_rv = app(environ, start_response) ../../venv/lib/python3.11/site-packages/flask/app.py:2551: in __call__ return self.wsgi_app(environ, start_response) ../../venv/lib/python3.11/site-packages/flask/app.py:2531: in wsgi_app response = self.handle_exception(e) ../../venv/lib/python3.11/site-packages/flask/app.py:2528: in wsgi_app response = self.full_dispatch_request() ../../venv/lib/python3.11/site-packages/flask/app.py:1825: in full_dispatch_request rv = self.handle_user_exception(e) ../../venv/lib/python3.11/site-packages/flask/app.py:1823: in full_dispatch_request rv = self.dispatch_request() ../../venv/lib/python3.11/site-packages/flask/app.py:1799: in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) ../inf349.py:293: in order_id_handler return put_order() ../inf349.py:282: in put_order return update_shipping_order(payload["order"]) ../inf349.py:217: in update_shipping_order return get_order() ../inf349.py:162: in get_order shipping_info = model_to_dict(ShippingInfo.get_or_none(order.shipping_info)) ../../venv/lib/python3.11/site-packages/peewee.py:6634: in get_or_none return cls.get(*query, **filters) ../../venv/lib/python3.11/site-packages/peewee.py:6629: in get return sq.get() ../../venv/lib/python3.11/site-packages/peewee.py:7077: in get return clone.execute(database)[0] ../../venv/lib/python3.11/site-packages/peewee.py:1962: in inner return method(self, database, *args, **kwargs) ../../venv/lib/python3.11/site-packages/peewee.py:2033: in execute return self._execute(database) ../../venv/lib/python3.11/site-packages/peewee.py:2206: in _execute cursor = database.execute(self) ../../venv/lib/python3.11/site-packages/peewee.py:3244: in execute return self.execute_sql(sql, params) ../../venv/lib/python3.11/site-packages/peewee.py:3234: in execute_sql with __exception_wrapper__: ../../venv/lib/python3.11/site-packages/peewee.py:3010: in __exit__ reraise(new_type, new_type(exc_value, *exc_args), traceback) ../../venv/lib/python3.11/site-packages/peewee.py:192: in reraise raise value.with_traceback(tb) ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/2704/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/2704/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/2703
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/2703/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/2703/comments
https://api.github.com/repos/coleifer/peewee/issues/2703/events
https://github.com/coleifer/peewee/issues/2703
1,661,723,222
I_kwDOAA7yGM5jC-JW
2,703
Failed constraints raises IntegrityError but exceeding max_length raises DataEror with postgres
{ "login": "TxMat", "id": 46858765, "node_id": "MDQ6VXNlcjQ2ODU4NzY1", "avatar_url": "https://avatars.githubusercontent.com/u/46858765?v=4", "gravatar_id": "", "url": "https://api.github.com/users/TxMat", "html_url": "https://github.com/TxMat", "followers_url": "https://api.github.com/users/TxMat/followers", "following_url": "https://api.github.com/users/TxMat/following{/other_user}", "gists_url": "https://api.github.com/users/TxMat/gists{/gist_id}", "starred_url": "https://api.github.com/users/TxMat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/TxMat/subscriptions", "organizations_url": "https://api.github.com/users/TxMat/orgs", "repos_url": "https://api.github.com/users/TxMat/repos", "events_url": "https://api.github.com/users/TxMat/events{/privacy}", "received_events_url": "https://api.github.com/users/TxMat/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "These errors are raised by postgres and passed on through psycopg2, which determines what error type to raise. Typically one would perform validation beforehand to eliminate something as simple as an over-length violation." ]
"2023-04-11T03:48:34"
"2023-04-11T11:57:35"
"2023-04-11T11:57:35"
NONE
null
```py # shipping info model class ShippingInfo(BaseModel): id = peewee.AutoField(primary_key=True, unique=True) country = peewee.CharField(null=False) address = peewee.CharField(null=False) postal_code = peewee.CharField(null=False, max_length=7, constraints=[peewee.Check('length(postal_code) = 7')]) city = peewee.CharField(null=False) province = peewee.CharField(null=False) ``` I don't know if it's intended but it makes catching for errors a bit trickier ```py try: shipping_info_instance = ShippingInfo.create(**shipping_info) order.shipping_info = shipping_info_instance except peewee.IntegrityError, peewee.DataError: return errors.error_handler("orders", "invalid-fields", "Les informations d'achat ne sont pas correctes"), 422 ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/2703/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/2703/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/2702
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/2702/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/2702/comments
https://api.github.com/repos/coleifer/peewee/issues/2702/events
https://github.com/coleifer/peewee/issues/2702
1,661,715,757
I_kwDOAA7yGM5jC8Ut
2,702
LIKE statement with postgres returns IndexError
{ "login": "TxMat", "id": 46858765, "node_id": "MDQ6VXNlcjQ2ODU4NzY1", "avatar_url": "https://avatars.githubusercontent.com/u/46858765?v=4", "gravatar_id": "", "url": "https://api.github.com/users/TxMat", "html_url": "https://github.com/TxMat", "followers_url": "https://api.github.com/users/TxMat/followers", "following_url": "https://api.github.com/users/TxMat/following{/other_user}", "gists_url": "https://api.github.com/users/TxMat/gists{/gist_id}", "starred_url": "https://api.github.com/users/TxMat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/TxMat/subscriptions", "organizations_url": "https://api.github.com/users/TxMat/orgs", "repos_url": "https://api.github.com/users/TxMat/repos", "events_url": "https://api.github.com/users/TxMat/events{/privacy}", "received_events_url": "https://api.github.com/users/TxMat/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "The \"%\" need to be escaped:\r\n\r\n```\r\nemail = peewee.CharField(null=True, constraints=[peewee.Check(\"email LIKE '%%@%%'\")])\r\n```" ]
"2023-04-11T03:37:04"
"2023-04-11T12:38:33"
"2023-04-11T12:38:14"
NONE
null
The like statement inside the email field is causing peewee to return an index error when constructing the database ```py class Order(BaseModel): id = peewee.AutoField(primary_key=True, unique=True) shipping_info = peewee.ForeignKeyField(ShippingInfo, backref='shipping_info', null=True) product = peewee.ForeignKeyField(Product, backref='product') email = peewee.CharField(null=True, constraints=[peewee.Check("email LIKE '%@%'")]) paid = peewee.BooleanField(null=False, default=False) credit_card = peewee.ForeignKeyField(CreditCard, backref='credit_card', null=True) transaction = peewee.ForeignKeyField(Transaction, backref='transaction', null=True) ``` ``` @pytest.fixture def client(): app.config['TESTING'] = True client = app.test_client() # init db db.connect() > db.create_tables([Product, ShippingInfo, Transaction, CreditCard, Order, OrderProduct]) conftest.py:16: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../../venv/lib/python3.11/site-packages/peewee.py:3425: in create_tables model.create_table(**options) ../../venv/lib/python3.11/site-packages/peewee.py:6865: in create_table cls._schema.create_all(safe, **options) ../../venv/lib/python3.11/site-packages/peewee.py:5967: in create_all self.create_table(safe, **table_options) ../../venv/lib/python3.11/site-packages/peewee.py:5818: in create_table self.database.execute(self._create_table(safe=safe, **options)) ../../venv/lib/python3.11/site-packages/peewee.py:3244: in execute return self.execute_sql(sql, params) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <peewee.PostgresqlDatabase object at 0x7fe651b025d0> sql = 'CREATE TABLE IF NOT EXISTS "order" ("id" SERIAL NOT NULL PRIMARY KEY, "shipping_info_id" INTEGER, "product_id" INTEGE...KEY ("credit_card_id") REFERENCES "creditcard" ("id"), FOREIGN KEY ("transaction_id") REFERENCES "transaction" ("id"))' params = [], commit = None def execute_sql(self, sql, params=None, commit=None): if commit is not None: __deprecated__('"commit" has been deprecated and is a no-op.') logger.debug((sql, params)) with __exception_wrapper__: cursor = self.cursor() > cursor.execute(sql, params or ()) E IndexError: tuple index out of range ../../venv/lib/python3.11/site-packages/peewee.py:3236: IndexError ``` it seems that some other fields causes the indexError error but i can't precisely identify them also i noticed the error because i'm migrating from sqlite to postgres
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/2702/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/2702/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/2701
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/2701/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/2701/comments
https://api.github.com/repos/coleifer/peewee/issues/2701/events
https://github.com/coleifer/peewee/issues/2701
1,657,252,090
I_kwDOAA7yGM5ix6j6
2,701
setup.py being deprecated
{ "login": "crdoconnor", "id": 6067509, "node_id": "MDQ6VXNlcjYwNjc1MDk=", "avatar_url": "https://avatars.githubusercontent.com/u/6067509?v=4", "gravatar_id": "", "url": "https://api.github.com/users/crdoconnor", "html_url": "https://github.com/crdoconnor", "followers_url": "https://api.github.com/users/crdoconnor/followers", "following_url": "https://api.github.com/users/crdoconnor/following{/other_user}", "gists_url": "https://api.github.com/users/crdoconnor/gists{/gist_id}", "starred_url": "https://api.github.com/users/crdoconnor/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/crdoconnor/subscriptions", "organizations_url": "https://api.github.com/users/crdoconnor/orgs", "repos_url": "https://api.github.com/users/crdoconnor/repos", "events_url": "https://api.github.com/users/crdoconnor/events{/privacy}", "received_events_url": "https://api.github.com/users/crdoconnor/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "What version of peewee are you using? I think this should be fixed since we have a magic pyproject toml file now.", "3.16.0, installed with python 3.11.2:\r\n\r\n```\r\nroot@6b1a08642656:/src# /venv/bin/pip install peewee==3.16.0 \r\nCollecting peewee==3.16.0\r\n Using cached peewee-3.16.0.tar.gz (866 kB)\r\n Preparing metadata (setup.py) ... done\r\nInstalling collected packages: peewee\r\n DEPRECATION: peewee is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559\r\n```\r\n\r\nI think your pyproject needs to have all of the details included.", "Oh I might have forgotten to add it to the manifest so it didn't get bundled! If you are able to look inside that cached peewee-3.16.0.tar.gz can you see if pyproject.toml is present?", "That might be it. Yes, it's missing.", "Thanks I'll get that added to the manifest. It's fine to ignore the warning in the meantime." ]
"2023-04-06T11:34:12"
"2023-04-06T12:10:17"
"2023-04-06T12:10:17"
NONE
null
This message is being displayed when pip installing peewee on python version 3.11.2: ``` DEPRECATION: peewee is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559 ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/2701/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/2701/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/2700
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/2700/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/2700/comments
https://api.github.com/repos/coleifer/peewee/issues/2700/events
https://github.com/coleifer/peewee/issues/2700
1,656,510,705
I_kwDOAA7yGM5ivFjx
2,700
Create aware datetime objects for TimestampField
{ "login": "IBuckton", "id": 48970269, "node_id": "MDQ6VXNlcjQ4OTcwMjY5", "avatar_url": "https://avatars.githubusercontent.com/u/48970269?v=4", "gravatar_id": "", "url": "https://api.github.com/users/IBuckton", "html_url": "https://github.com/IBuckton", "followers_url": "https://api.github.com/users/IBuckton/followers", "following_url": "https://api.github.com/users/IBuckton/following{/other_user}", "gists_url": "https://api.github.com/users/IBuckton/gists{/gist_id}", "starred_url": "https://api.github.com/users/IBuckton/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/IBuckton/subscriptions", "organizations_url": "https://api.github.com/users/IBuckton/orgs", "repos_url": "https://api.github.com/users/IBuckton/repos", "events_url": "https://api.github.com/users/IBuckton/events{/privacy}", "received_events_url": "https://api.github.com/users/IBuckton/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "You can't compare naive and tz-aware datetimes, so this is a non-starter unfortunately. The idea is that your naive datetime *is* already in UTC so the tzinfo is meaningless and provides flexibility -- that is *also* why `utc=False` by default. We can't be switching the return value between naive and tz-aware based on the value of the `utc` parameter.\r\n\r\nMy suggestion would be to subclass `TimestampField` and override the `python_value()` if you wish, e.g.\r\n\r\n```python\r\nclass UTCTimestampField(TimestampField):\r\n def __init__(self, **kwargs):\r\n kwargs['utc'] = True\r\n super(UTCTimestampField, self).__init__(**kwargs)\r\n def python_value(self, value):\r\n value = super(UTCTimestampField, self).python_value(value)\r\n if value is not None:\r\n return value.replace(tzinfo=datetime.timezone.utc)\r\n```" ]
"2023-04-06T00:55:51"
"2023-04-06T04:02:53"
"2023-04-06T04:02:52"
NONE
null
**Description** With `TimestampField(utc=True)` it returns a naive datetime object. This is not recommended as they are treated by many datetime methods as local times. **Expected behaviour** Return an aware datetime object to avoid confusion, per the recommendation in [datetime docs](https://docs.python.org/3.11/library/datetime.html#datetime.datetime.utcfromtimestamp) **Suggested change** ```python if self.utc: - value = datetime.datetime.utcfromtimestamp(value) + value = datetime.datetime.fromtimestamp(value, datetime.timezone.utc) ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/2700/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/2700/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/2699
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/2699/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/2699/comments
https://api.github.com/repos/coleifer/peewee/issues/2699/events
https://github.com/coleifer/peewee/issues/2699
1,652,084,899
I_kwDOAA7yGM5ieNCj
2,699
test_multiple_writers failing with database is locked on ppc64le arch
{ "login": "vkrizan", "id": 7695766, "node_id": "MDQ6VXNlcjc2OTU3NjY=", "avatar_url": "https://avatars.githubusercontent.com/u/7695766?v=4", "gravatar_id": "", "url": "https://api.github.com/users/vkrizan", "html_url": "https://github.com/vkrizan", "followers_url": "https://api.github.com/users/vkrizan/followers", "following_url": "https://api.github.com/users/vkrizan/following{/other_user}", "gists_url": "https://api.github.com/users/vkrizan/gists{/gist_id}", "starred_url": "https://api.github.com/users/vkrizan/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/vkrizan/subscriptions", "organizations_url": "https://api.github.com/users/vkrizan/orgs", "repos_url": "https://api.github.com/users/vkrizan/repos", "events_url": "https://api.github.com/users/vkrizan/events{/privacy}", "received_events_url": "https://api.github.com/users/vkrizan/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Thanks for the report. That timing for the tests (500+ seconds) is unreal, for comparison they run in less than 4 seconds on my workstation:\r\n\r\n```\r\nRan 1154 tests in 3.359s\r\n```\r\n\r\nSo I wonder if you are hitting the sqlite busy timeout on that particular test-case. Is there a particular test that is slowing things down? Even on a small, lightly provisioned VM I'd expect them to run much more quickly than your timing.", "You can also try this patch or one like it to see if eliminates the failure:\r\n\r\n```diff\r\ndiff --git a/tests/db_tests.py b/tests/db_tests.py\r\nindex 593abe40..f38d14e0 100644\r\n--- a/tests/db_tests.py\r\n+++ b/tests/db_tests.py\r\n@@ -23,6 +23,7 @@ from .base import TestModel\r\n from .base import db\r\n from .base import db_loader\r\n from .base import get_in_memory_db\r\n+from .base import new_connection\r\n from .base import requires_models\r\n from .base import requires_postgresql\r\n from .base_models import Category\r\n@@ -348,6 +349,8 @@ class TestDatabase(DatabaseTestCase):\r\n \r\n \r\n class TestThreadSafety(ModelTestCase):\r\n+ if IS_SQLITE:\r\n+ database = new_connection(timeout=30)\r\n nthreads = 4\r\n nrows = 10\r\n requires = [User]\r\n```", "Here is the full build: https://koji.fedoraproject.org/koji/taskinfo?taskID=99476458\r\n\r\nInterestingly other archs are running slow as well:\r\n* x86_64 -- Ran 1147 tests in 16.497s\r\n* aarch64 (ARM64) -- Ran 1147 tests in 11.318s\r\n* s390x (IBM System/390) -- Ran 1147 tests in 22.812s\r\n\r\nThis runs on build system ([Koji](https://fedoraproject.org/wiki/Koji)). I think build nodes should have enough resources to complete a build.\r\n\r\nI can try to apply the suggested fix and do a scratch build. However, the test run seems a bit off based on your comment.", "Build of 3.15.4 was slow as well https://koji.fedoraproject.org/koji/buildinfo?buildID=2128823 (16s on x86_64).", "Test runs on the order of 10's of seconds is definitely no problem and nothing to worry about, even 100-200s is likely just indicative of a slow machine and/or disk and no real problem.\r\n\r\nOn my workstation I used the above patch with the timeout set to `0.001` and was able to replicate this type of failure -- so my guess is that the ppc64le arch is just performing terribly on our testcases (for whatever reason). By default we give Sqlite 5s to acquire that lock in the multiple writers tests which is ordinarily orders of magnitude more than necessary (for comparison setting it to `0.01` was still plenty of time and did not replicate the issue).\r\n\r\nDo you all maintain any patches for peewee? If so you can try adding the above patch I shared or just marking the test as allowed failure.", "Currently there are no patches applied, but we can create any that would be necessary. I'll try that...\r\nHaving patches in the upstream (this repository) would be the best option.\r\n\r\nHere is the packaging repository https://src.fedoraproject.org/rpms/python-peewee/tree/rawhide (build is defined within an [RPM spec](https://rpm-packaging-guide.github.io/)) \r\nHere's where test run is defined https://src.fedoraproject.org/rpms/python-peewee/blob/rawhide/f/python-peewee.spec#_90", "@vkrizan - try the above commit, https://github.com/coleifer/peewee/commit/027eccff176bf458972900d6a329e05d5b969eb4 and let's see if that addresses the issue.", "@coleifer I'll try to apply it as a patch and see (tomorrow). Unfortunately the [build spec follows git version tags](https://src.fedoraproject.org/rpms/python-peewee/blob/rawhide/f/python-peewee.spec#_16) for me to test it quickly (without applying a patch).", "If this were a legit issue I'd be more concerned, but this seems to be a confluence of some kind of build environment issues manifesting as a test-only failure, so take heart: all is well.", "I've tried the patch and this time 3 tests have failed and it got deadlocked :slightly_frowning_face: .\r\n* 2x tests.pool.TestPooledDatabaseIntegration.test_pool_with_models\r\n* tests.pool.TestPooledDatabaseIntegration.test_pooled_database_integration\r\n\r\n```\r\npeewee.OperationalError: database is locked\r\n----------------------------------------------------------------------\r\nRan 1147 tests in 484.713s\r\nFAILED (errors=3, skipped=112)\r\nUnable to import SQLCipher extension tests, skipping.\r\n```\r\nThat was the last log message. It never exited, I had to cancel the build job today.\r\n\r\nThe version of sqlite is: `sqlite-libs-3.40.1-2.fc38.ppc64le`.\r\n(It succeeded on Fedora in development F39. That one has `sqlite-libs-3.41.2-1.fc39.ppc64le`.)\r\n\r\nhttps://koji.fedoraproject.org/koji/taskinfo?taskID=99517867", "On second try it went through -- build succeeded. The behavior seems a bit non-deterministic. ", "Id suggest looking into why the performance on ppc64le is so abysmal. I think you mentioned most other architectures finished in 10-15s, so 400-500+ seems unreasonably slow.", "3.16.1 released." ]
"2023-04-03T13:34:00"
"2023-04-18T17:11:16"
"2023-04-03T14:41:20"
NONE
null
Hello, The `tests.db_tests.TestThreadSafety.test_multiple_writers` test is failing on ppc64le architecture with: ``` peewee.OperationalError: database is locked ``` ``` + createdb peewee_test + psql -c 'CREATE EXTENSION hstore' peewee_test CREATE EXTENSION + /usr/bin/python3 runtests.py ...................................................................................s................ssssssssssssssssssssssssssssssssss...................s..........................sss............................................s.......ss............................s.................s........ssss..................................................................................s..........................................................................ssssss...........................ss..............................................s...................................................................................................................................................s.ss.................ssss............................................ss...............................s..................s...........ss...............................s....ss......s..............s..............................................................ss...............................................................Exception in thread Thread-47 (create_users): Traceback (most recent call last): File "/builddir/build/BUILD/peewee-3.16.0/peewee.py", line 3236, in execute_sql Exception in thread Thread-46 (create_users): Traceback (most recent call last): File "/builddir/build/BUILD/peewee-3.16.0/peewee.py", line 3236, in execute_sql cursor.execute(sql, params or ()) cursor.execute(sql, params or ()) sqlite3.OperationalError: database is locked During handling of the above exception, another exception occurred: sqlite3.OperationalError: database is locked During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/lib64/python3.11/threading.py", line 1038, in _bootstrap_inner Traceback (most recent call last): File "/usr/lib64/python3.11/threading.py", line 1038, in _bootstrap_inner self.run() File "/usr/lib64/python3.11/threading.py", line 975, in run self._target(*self._args, **self._kwargs) File "/builddir/build/BUILD/peewee-3.16.0/tests/db_tests.py", line 358, in create_users self.run() File "/usr/lib64/python3.11/threading.py", line 975, in run User.create(username='u%d' % i) File "/builddir/build/BUILD/peewee-3.16.0/peewee.py", line 6537, in create self._target(*self._args, **self._kwargs) File "/builddir/build/BUILD/peewee-3.16.0/tests/db_tests.py", line 358, in create_users User.create(username='u%d' % i) File "/builddir/build/BUILD/peewee-3.16.0/peewee.py", line 6537, in create inst.save(force_insert=True) File "/builddir/build/BUILD/peewee-3.16.0/peewee.py", line 6747, in save inst.save(force_insert=True) File "/builddir/build/BUILD/peewee-3.16.0/peewee.py", line 6747, in save pk = self.insert(**field_dict).execute() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/builddir/build/BUILD/peewee-3.16.0/peewee.py", line 1962, in inner return method(self, database, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/builddir/build/BUILD/peewee-3.16.0/peewee.py", line 2033, in execute return self._execute(database) ^^^^^^^^^^^^^^^^^^^^^^^ File "/builddir/build/BUILD/peewee-3.16.0/peewee.py", line 2838, in _execute return super(Insert, self)._execute(database) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/builddir/build/BUILD/peewee-3.16.0/peewee.py", line 2551, in _execute pk = self.insert(**field_dict).execute() cursor = database.execute(self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/builddir/build/BUILD/peewee-3.16.0/peewee.py", line 1962, in inner ^^^^^^^^^^^^^^^^^^^^^^ File "/builddir/build/BUILD/peewee-3.16.0/peewee.py", line 3244, in execute return method(self, database, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/builddir/build/BUILD/peewee-3.16.0/peewee.py", line 2033, in execute return self._execute(database) return self.execute_sql(sql, params) ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/builddir/build/BUILD/peewee-3.16.0/peewee.py", line 3234, in execute_sql File "/builddir/build/BUILD/peewee-3.16.0/peewee.py", line 2838, in _execute with __exception_wrapper__: File "/builddir/build/BUILD/peewee-3.16.0/peewee.py", line 3010, in __exit__ reraise(new_type, new_type(exc_value, *exc_args), traceback) File "/builddir/build/BUILD/peewee-3.16.0/peewee.py", line 192, in reraise return super(Insert, self)._execute(database) raise value.with_traceback(tb) File "/builddir/build/BUILD/peewee-3.16.0/peewee.py", line 3236, in execute_sql ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/builddir/build/BUILD/peewee-3.16.0/peewee.py", line 2551, in _execute cursor.execute(sql, params or ()) peewee.OperationalError: database is locked cursor = database.execute(self) ^^^^^^^^^^^^^^^^^^^^^^ File "/builddir/build/BUILD/peewee-3.16.0/peewee.py", line 3244, in execute return self.execute_sql(sql, params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/builddir/build/BUILD/peewee-3.16.0/peewee.py", line 3234, in execute_sql with __exception_wrapper__: File "/builddir/build/BUILD/peewee-3.16.0/peewee.py", line 3010, in __exit__ reraise(new_type, new_type(exc_value, *exc_args), traceback) File "/builddir/build/BUILD/peewee-3.16.0/peewee.py", line 192, in reraise raise value.with_traceback(tb) File "/builddir/build/BUILD/peewee-3.16.0/peewee.py", line 3236, in execute_sql cursor.execute(sql, params or ()) peewee.OperationalError: database is locked Fssssssss..............................sssssss........sss.......ssssssssssssss.....s........................s.................................. ====================================================================== FAIL: test_multiple_writers (tests.db_tests.TestThreadSafety.test_multiple_writers) ---------------------------------------------------------------------- Traceback (most recent call last): File "/builddir/build/BUILD/peewee-3.16.0/tests/db_tests.py", line 367, in test_multiple_writers self.assertEqual(User.select().count(), self.nrows * self.nthreads) AssertionError: 20 != 40 ``` Full log: https://kojipkgs.fedoraproject.org//work/tasks/6601/99476601/build.log Failing build: https://koji.fedoraproject.org/koji/taskinfo?taskID=99476601 Thank you.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/2699/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/2699/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/2698
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/2698/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/2698/comments
https://api.github.com/repos/coleifer/peewee/issues/2698/events
https://github.com/coleifer/peewee/pull/2698
1,641,066,536
PR_kwDOAA7yGM5M6wfI
2,698
Ae configurable default
{ "login": "paetling", "id": 3281726, "node_id": "MDQ6VXNlcjMyODE3MjY=", "avatar_url": "https://avatars.githubusercontent.com/u/3281726?v=4", "gravatar_id": "", "url": "https://api.github.com/users/paetling", "html_url": "https://github.com/paetling", "followers_url": "https://api.github.com/users/paetling/followers", "following_url": "https://api.github.com/users/paetling/following{/other_user}", "gists_url": "https://api.github.com/users/paetling/gists{/gist_id}", "starred_url": "https://api.github.com/users/paetling/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/paetling/subscriptions", "organizations_url": "https://api.github.com/users/paetling/orgs", "repos_url": "https://api.github.com/users/paetling/repos", "events_url": "https://api.github.com/users/paetling/events{/privacy}", "received_events_url": "https://api.github.com/users/paetling/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Is there a reason you are not just using:\r\n\r\n```python\r\nclass Base(Model):\r\n id = BinaryUUIDField(primary_key=True, ...)\r\n\r\nclass MyModel(Base):\r\n # MyModel.id will be a binary uuid field\r\n```\r\n\r\nThis change seems redundant." ]
"2023-03-26T20:10:10"
"2023-03-27T12:48:35"
"2023-03-27T12:48:30"
NONE
null
## Context Make it so that we can configure the type of the id that is created
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/2698/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/2698/timeline
null
null
true
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/2698", "html_url": "https://github.com/coleifer/peewee/pull/2698", "diff_url": "https://github.com/coleifer/peewee/pull/2698.diff", "patch_url": "https://github.com/coleifer/peewee/pull/2698.patch", "merged_at": null }
https://api.github.com/repos/coleifer/peewee/issues/2697
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/2697/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/2697/comments
https://api.github.com/repos/coleifer/peewee/issues/2697/events
https://github.com/coleifer/peewee/issues/2697
1,634,492,330
I_kwDOAA7yGM5hbF-q
2,697
peewee-value-returns-to-its-default-after-few-seconds-bug
{ "login": "instasck", "id": 43851500, "node_id": "MDQ6VXNlcjQzODUxNTAw", "avatar_url": "https://avatars.githubusercontent.com/u/43851500?v=4", "gravatar_id": "", "url": "https://api.github.com/users/instasck", "html_url": "https://github.com/instasck", "followers_url": "https://api.github.com/users/instasck/followers", "following_url": "https://api.github.com/users/instasck/following{/other_user}", "gists_url": "https://api.github.com/users/instasck/gists{/gist_id}", "starred_url": "https://api.github.com/users/instasck/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/instasck/subscriptions", "organizations_url": "https://api.github.com/users/instasck/orgs", "repos_url": "https://api.github.com/users/instasck/repos", "events_url": "https://api.github.com/users/instasck/events{/privacy}", "received_events_url": "https://api.github.com/users/instasck/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "OK ISSUES IS\r\nThat a pointer to the database is not refreshing automatically, it pointing to local data in memory so holding old data.", "Don't spam the issues -- please try to have a bit of patience.", "Well it took me 2 hours before I found the issue.\r\nit is not clear about refreshing data from the doc..." ]
"2023-03-21T18:26:54"
"2023-03-21T19:09:42"
"2023-03-21T19:06:38"
NONE
null
https://stackoverflow.com/questions/75804965/peewee-value-returns-to-its-default-after-few-seconds-bug Can you explain this ?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/2697/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/2697/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/2696
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/2696/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/2696/comments
https://api.github.com/repos/coleifer/peewee/issues/2696/events
https://github.com/coleifer/peewee/issues/2696
1,634,154,999
I_kwDOAA7yGM5hZzn3
2,696
Point type
{ "login": "diegocatalao", "id": 81654879, "node_id": "MDQ6VXNlcjgxNjU0ODc5", "avatar_url": "https://avatars.githubusercontent.com/u/81654879?v=4", "gravatar_id": "", "url": "https://api.github.com/users/diegocatalao", "html_url": "https://github.com/diegocatalao", "followers_url": "https://api.github.com/users/diegocatalao/followers", "following_url": "https://api.github.com/users/diegocatalao/following{/other_user}", "gists_url": "https://api.github.com/users/diegocatalao/gists{/gist_id}", "starred_url": "https://api.github.com/users/diegocatalao/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/diegocatalao/subscriptions", "organizations_url": "https://api.github.com/users/diegocatalao/orgs", "repos_url": "https://api.github.com/users/diegocatalao/repos", "events_url": "https://api.github.com/users/diegocatalao/events{/privacy}", "received_events_url": "https://api.github.com/users/diegocatalao/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "No plans on integrating this into Peewee at the present." ]
"2023-03-21T15:22:36"
"2023-03-21T15:25:31"
"2023-03-21T15:25:30"
NONE
null
Good afternoon people. Most databases implement the Point type. I've implemented a custom type but I don't know if that's on your roadmap. I would like to implement it natively in PeeWee.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/2696/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/2696/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/2695
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/2695/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/2695/comments
https://api.github.com/repos/coleifer/peewee/issues/2695/events
https://github.com/coleifer/peewee/issues/2695
1,630,086,918
I_kwDOAA7yGM5hKScG
2,695
FOR UPDATE not supported by CockroachDatabase
{ "login": "arel", "id": 153497, "node_id": "MDQ6VXNlcjE1MzQ5Nw==", "avatar_url": "https://avatars.githubusercontent.com/u/153497?v=4", "gravatar_id": "", "url": "https://api.github.com/users/arel", "html_url": "https://github.com/arel", "followers_url": "https://api.github.com/users/arel/followers", "following_url": "https://api.github.com/users/arel/following{/other_user}", "gists_url": "https://api.github.com/users/arel/gists{/gist_id}", "starred_url": "https://api.github.com/users/arel/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/arel/subscriptions", "organizations_url": "https://api.github.com/users/arel/orgs", "repos_url": "https://api.github.com/users/arel/repos", "events_url": "https://api.github.com/users/arel/events{/privacy}", "received_events_url": "https://api.github.com/users/arel/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Thank you for letting me know, I'll get this fixed.\r\n\r\nIn the meantime you can set the flag manually when you do your database initialization.\r\n\r\n```\r\ndb = ...\r\ndb.for_update = True\r\n```", "Thanks!", "When I enabled the flag the crdb tests are locking up and failing, so something must be special about their implementation. If you're able to look into it that'd be great but if not I'll get around to it. (runtests.py -e cockroachdb)", "I'm just marking the locked tests to skip for CockroachDB. I have no clue why it isn't working like Postgres or MySQL. This should be resolved now by:\r\n\r\n0031ca565651bc3fd4a12ba347c4cb76c99a643f and 7357d9303a07826bab539a508f05b534f6fcbcc1" ]
"2023-03-18T02:06:31"
"2023-03-18T21:13:38"
"2023-03-18T21:13:37"
NONE
null
I believe this is a bug. I am getting the following error when I try to use `for_update()` in Cockroach DB: ``` File "/workspace/nuhom-api/.venv/lib/python3.10/site-packages/peewee.py", line 2509, in __sql__ raise ValueError('FOR UPDATE specified but not supported ' graphql.error.graphql_error.GraphQLError: FOR UPDATE specified but not supported by database. ``` It looks like `CockroachDatabase` believes `FOR UPDATE` is not supported (which may have been the case in an earlier version): https://github.com/coleifer/peewee/blob/b5cee5e99bcc0b20010646cb52c60f8e37dd620a/playhouse/cockroachdb.py#L65 But, in the CockroachDB docs, it states that `FOR UPDATE` is now supported: https://www.cockroachlabs.com/docs/stable/select-for-update.html And, even though CockroachDB does not support [locking strengths](https://www.cockroachlabs.com/docs/v22.2/select-for-update#locking-strengths) (`FOR SHARE` or `FOR KEY SHARE`), the syntax is also supported to be compatible with Postgres.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/2695/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/2695/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/2694
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/2694/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/2694/comments
https://api.github.com/repos/coleifer/peewee/issues/2694/events
https://github.com/coleifer/peewee/issues/2694
1,629,501,735
I_kwDOAA7yGM5hIDkn
2,694
`CharField.max_length` has no effect on a Sqlite database
{ "login": "calvinweb", "id": 38599774, "node_id": "MDQ6VXNlcjM4NTk5Nzc0", "avatar_url": "https://avatars.githubusercontent.com/u/38599774?v=4", "gravatar_id": "", "url": "https://api.github.com/users/calvinweb", "html_url": "https://github.com/calvinweb", "followers_url": "https://api.github.com/users/calvinweb/followers", "following_url": "https://api.github.com/users/calvinweb/following{/other_user}", "gists_url": "https://api.github.com/users/calvinweb/gists{/gist_id}", "starred_url": "https://api.github.com/users/calvinweb/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/calvinweb/subscriptions", "organizations_url": "https://api.github.com/users/calvinweb/orgs", "repos_url": "https://api.github.com/users/calvinweb/repos", "events_url": "https://api.github.com/users/calvinweb/events{/privacy}", "received_events_url": "https://api.github.com/users/calvinweb/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "That is correct, and is down to the way SQLite implements text affinity columns.\r\n\r\nIf you want to enforce a max length you can add a check constraint or implement a subclass of charfield that overrides the `db_value()` method to trim the string.", "> That is correct, and is down to the way SQLite implements text affinity columns.\r\n> \r\n> If you want to enforce a max length you can add a check constraint or implement a subclass of charfield that overrides the `db_value()` method to trim the string.\r\n\r\nbut i think this should be done by peewee itself because databases should have same behavour" ]
"2023-03-17T15:23:13"
"2023-03-18T01:57:47"
"2023-03-17T16:16:44"
NONE
null
null
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/2694/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/2694/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/2693
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/2693/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/2693/comments
https://api.github.com/repos/coleifer/peewee/issues/2693/events
https://github.com/coleifer/peewee/issues/2693
1,628,079,936
I_kwDOAA7yGM5hCodA
2,693
peewee.ProgrammingError: Error binding parameter 1: type 'builtin_function_or_method' is not supported
{ "login": "RanjithSivam", "id": 57189095, "node_id": "MDQ6VXNlcjU3MTg5MDk1", "avatar_url": "https://avatars.githubusercontent.com/u/57189095?v=4", "gravatar_id": "", "url": "https://api.github.com/users/RanjithSivam", "html_url": "https://github.com/RanjithSivam", "followers_url": "https://api.github.com/users/RanjithSivam/followers", "following_url": "https://api.github.com/users/RanjithSivam/following{/other_user}", "gists_url": "https://api.github.com/users/RanjithSivam/gists{/gist_id}", "starred_url": "https://api.github.com/users/RanjithSivam/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/RanjithSivam/subscriptions", "organizations_url": "https://api.github.com/users/RanjithSivam/orgs", "repos_url": "https://api.github.com/users/RanjithSivam/repos", "events_url": "https://api.github.com/users/RanjithSivam/events{/privacy}", "received_events_url": "https://api.github.com/users/RanjithSivam/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Do not post questions like this on here. Post your questions on stack overflow. The error is extremely basic, and the error message tells you what is going on. You cannot pass a function as a query parameter.\r\n\r\n```python\r\n# Actually call .now(), don't pass the function itself:\r\n.update(last_login=datetime.datetime.now())\r\n```" ]
"2023-03-16T18:45:53"
"2023-03-16T18:55:45"
"2023-03-16T18:55:44"
NONE
null
I am trying to update. I get this error. My Code: ![image](https://user-images.githubusercontent.com/57189095/225722329-ac69c23c-d0d4-44bc-8571-aba021a24f28.png) Here is the error: Traceback (most recent call last): File "C:\Users\ranjith-15557\AppData\Local\Programs\Python\Python311\Lib\site-packages\peewee.py", line 3236, in execute_sql cursor.execute(sql, params or ()) sqlite3.ProgrammingError: Error binding parameter 1: type 'builtin_function_or_method' is not supported During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\ranjith-15557\AppData\Local\Programs\Python\Python311\Lib\site-packages\eel\__init__.py", line 318, in _process_message return_val = _exposed_functions[message['name']](*message['args']) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "E:\personal\Shoonya\start.py", line 39, in loginDefault dbHelper.updateLastLogin() File "E:\personal\Shoonya\lib\db.py", line 63, in updateLastLogin Credential.update(last_login=datetime.datetime.now).where(Credential.is_default == True).execute() File "C:\Users\ranjith-15557\AppData\Local\Programs\Python\Python311\Lib\site-packages\peewee.py", line 1962, in inner return method(self, database, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ranjith-15557\AppData\Local\Programs\Python\Python311\Lib\site-packages\peewee.py", line 2033, in execute return self._execute(database) ^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ranjith-15557\AppData\Local\Programs\Python\Python311\Lib\site-packages\peewee.py", line 2551, in _execute cursor = database.execute(self) ^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ranjith-15557\AppData\Local\Programs\Python\Python311\Lib\site-packages\peewee.py", line 3244, in execute return self.execute_sql(sql, params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ranjith-15557\AppData\Local\Programs\Python\Python311\Lib\site-packages\peewee.py", line 3234, in execute_sql with __exception_wrapper__: File "C:\Users\ranjith-15557\AppData\Local\Programs\Python\Python311\Lib\site-packages\peewee.py", line 3010, in __exit__ reraise(new_type, new_type(exc_value, *exc_args), traceback) File "C:\Users\ranjith-15557\AppData\Local\Programs\Python\Python311\Lib\site-packages\peewee.py", line 192, in reraise raise value.with_traceback(tb) File "C:\Users\ranjith-15557\AppData\Local\Programs\Python\Python311\Lib\site-packages\peewee.py", line 3236, in execute_sql cursor.execute(sql, params or ()) peewee.ProgrammingError: Error binding parameter 1: type 'builtin_function_or_method' is not supported Traceback (most recent call last): File "C:\Users\ranjith-15557\AppData\Local\Programs\Python\Python311\Lib\site-packages\gevent\_ffi\loop.py", line 270, in python_check_callback def python_check_callback(self, watcher_ptr): # pylint:disable=unused-argument ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ranjith-15557\AppData\Local\Programs\Python\Python311\Lib\site-packages\peewee.py", line 2033, in execute return self._execute(database) ^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ranjith-15557\AppData\Local\Programs\Python\Python311\Lib\site-packages\peewee.py", line 2551, in _execute cursor = database.execute(self) ^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ranjith-15557\AppData\Local\Programs\Python\Python311\Lib\site-packages\peewee.py", line 3244, in execute return self.execute_sql(sql, params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ranjith-15557\AppData\Local\Programs\Python\Python311\Lib\site-packages\peewee.py", line 3234, in execute_sql with __exception_wrapper__: File "C:\Users\ranjith-15557\AppData\Local\Programs\Python\Python311\Lib\site-packages\peewee.py", line 3010, in __exit__ reraise(new_type, new_type(exc_value, *exc_args), traceback) File "C:\Users\ranjith-15557\AppData\Local\Programs\Python\Python311\Lib\site-packages\peewee.py", line 192, in reraise raise value.with_traceback(tb) File "C:\Users\ranjith-15557\AppData\Local\Programs\Python\Python311\Lib\site-packages\peewee.py", line 3236, in execute_sql cursor.execute(sql, params) peewee.ProgrammingError: Error binding parameter 1: type 'builtin_function_or_method' is not supported
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/2693/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/2693/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/2692
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/2692/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/2692/comments
https://api.github.com/repos/coleifer/peewee/issues/2692/events
https://github.com/coleifer/peewee/issues/2692
1,623,585,150
I_kwDOAA7yGM5gxfF-
2,692
Creating indexes on UUID primary key failes
{ "login": "martijnED", "id": 104991209, "node_id": "U_kgDOBkIJ6Q", "avatar_url": "https://avatars.githubusercontent.com/u/104991209?v=4", "gravatar_id": "", "url": "https://api.github.com/users/martijnED", "html_url": "https://github.com/martijnED", "followers_url": "https://api.github.com/users/martijnED/followers", "following_url": "https://api.github.com/users/martijnED/following{/other_user}", "gists_url": "https://api.github.com/users/martijnED/gists{/gist_id}", "starred_url": "https://api.github.com/users/martijnED/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/martijnED/subscriptions", "organizations_url": "https://api.github.com/users/martijnED/orgs", "repos_url": "https://api.github.com/users/martijnED/repos", "events_url": "https://api.github.com/users/martijnED/events{/privacy}", "received_events_url": "https://api.github.com/users/martijnED/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "The docs are pretty clear:\r\n\r\n```python\r\n# Adding an index:\r\n\r\n# Specify the table, column names, and whether the index should be\r\n# UNIQUE or not.\r\nmigrate(\r\n # Create an index on the `pub_date` column.\r\n migrator.add_index('story', ('pub_date',), False),\r\n\r\n # Create a multi-column index on the `pub_date` and `status` fields.\r\n migrator.add_index('story', ('pub_date', 'status'), False),\r\n\r\n # Create a unique index on the category and title fields.\r\n migrator.add_index('story', ('category_id', 'title'), True),\r\n)\r\n```\r\n\r\nPlease at least look at the docs before opening an issue in the future.", "On closer inspection it looks like this isn't even for peewee, but for a third-party package. Please refer to the 3rd party package maintainer's documentation or take it up with them.", "If I do so, I get a different error:\r\n\r\n## Code\r\n``` python\r\nimport uuid\r\nfrom peewee import UUIDField,\r\n\r\n\r\nclass CommandControl(Model):\r\n id = UUIDField(primary_key=True, default=uuid.uuid4)\r\n\r\ndef migrate(migrator, database, fake=False, **kwargs):\r\n \"\"\"Write your migrations here.\"\"\"\r\n migrator.create_table(CommandControl)\r\n migrator.add_index('command_control', ('id',), False)\r\n\r\n```\r\n\r\n## The error than\r\n``` bash\r\nTypeError: not all arguments converted during string formatting\r\n```\r\nbit unclear what this means and how to solve that part", "You aren't showing what `migrator` is but from your earlier comment I inferred it is some 3rd party library `peewee_migrate`? Please refer there.", "You completely right! Will ask the question there!" ]
"2023-03-14T14:19:57"
"2023-03-14T14:41:00"
"2023-03-14T14:25:14"
NONE
null
During creating of tables and creating indexes on that table it failes to create indexes on UUID key. ## The code ``` python import uuid from playhouse.postgres_ext import UUIDField class CommandControl(Model): id = UUIDField(primary_key=True, default=uuid.uuid4) def migrate(migrator, database, fake=False, **kwargs): """Write your migrations here.""" migrator.create_table(CommandControl) migrator.add_index(CommandControl.id) ``` ## The error ``` bash File "/app/__pypackages__/3.10/lib/peewee_migrate/migrator.py", line 117, in wrapper model._meta.schema = migrator.schema AttributeError: 'UUIDField' object has no attribute '_meta' ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/2692/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/2692/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/2691
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/2691/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/2691/comments
https://api.github.com/repos/coleifer/peewee/issues/2691/events
https://github.com/coleifer/peewee/issues/2691
1,619,326,207
I_kwDOAA7yGM5ghPT_
2,691
reflection.generate_models BinaryJSONField column always has index, even when underlying database schema has no index
{ "login": "rberman", "id": 6520506, "node_id": "MDQ6VXNlcjY1MjA1MDY=", "avatar_url": "https://avatars.githubusercontent.com/u/6520506?v=4", "gravatar_id": "", "url": "https://api.github.com/users/rberman", "html_url": "https://github.com/rberman", "followers_url": "https://api.github.com/users/rberman/followers", "following_url": "https://api.github.com/users/rberman/following{/other_user}", "gists_url": "https://api.github.com/users/rberman/gists{/gist_id}", "starred_url": "https://api.github.com/users/rberman/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/rberman/subscriptions", "organizations_url": "https://api.github.com/users/rberman/orgs", "repos_url": "https://api.github.com/users/rberman/repos", "events_url": "https://api.github.com/users/rberman/events{/privacy}", "received_events_url": "https://api.github.com/users/rberman/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[]
"2023-03-10T17:16:36"
"2023-03-10T19:03:17"
"2023-03-10T19:03:17"
NONE
null
I have a table defined as follows: ```python from playhouse.postgres_ext import BinaryJSONField class MyTable(flask_db.Model): some_data = BinaryJSONField(index=False) ``` For this table, we don’t need an index since we only ever write to this table. When I try to use generate_models on this table, the generated BinaryJSONField has `index=True`, as demonstrated below: ```python from playhouse.reflection import generate_models from models import MyTable generated_model = generate_models(flask_db.database, table_names=["mytable"])["mytable"] generated_column = generated_model._meta.columns["some_data"] reference_column = MyTable._meta.columns["some_data"] # Raises an error: assert generated_column.index == reference_column.index ``` I believe this is happening because `BinaryJSONField` inherits from `IndexedFieldMixin` and, therefore, defaults the `index` parameter to `True`. The reflection code checks for indexes and adds `index=True` to column definitions when necessary to create the corresponding indexes, but does not add `index=False` when they are not required ([see here](https://github.com/coleifer/peewee/blob/3fc96dbe33500d3e5099ea11ef7af080900127ba/playhouse/reflection.py#L762-L767)). That normally works, but not for column types that include `IndexedFieldMixin`. The preferred behavior would be for the `index=False` value to taken into account when creating the table. Would you please take a look? Thank you!
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/2691/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/2691/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/2690
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/2690/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/2690/comments
https://api.github.com/repos/coleifer/peewee/issues/2690/events
https://github.com/coleifer/peewee/issues/2690
1,618,951,492
I_kwDOAA7yGM5gfz1E
2,690
Prefetch with many ForeignKeyField to same model
{ "login": "dim49v", "id": 15666913, "node_id": "MDQ6VXNlcjE1NjY2OTEz", "avatar_url": "https://avatars.githubusercontent.com/u/15666913?v=4", "gravatar_id": "", "url": "https://api.github.com/users/dim49v", "html_url": "https://github.com/dim49v", "followers_url": "https://api.github.com/users/dim49v/followers", "following_url": "https://api.github.com/users/dim49v/following{/other_user}", "gists_url": "https://api.github.com/users/dim49v/gists{/gist_id}", "starred_url": "https://api.github.com/users/dim49v/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/dim49v/subscriptions", "organizations_url": "https://api.github.com/users/dim49v/orgs", "repos_url": "https://api.github.com/users/dim49v/repos", "events_url": "https://api.github.com/users/dim49v/events{/privacy}", "received_events_url": "https://api.github.com/users/dim49v/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Seems to be working OK for me:\r\n\r\n```python\r\nclass State(db.Model):\r\n name = TextField()\r\n def __str__(self):\r\n return self.name\r\n\r\nclass Transition(db.Model):\r\n source_state = ForeignKeyField(State, backref='sources')\r\n target_state = ForeignKeyField(State, backref='targets')\r\n def __str__(self):\r\n return '%s->%s' % (self.source_state, self.target_state)\r\n\r\ndb.create_tables([State, Transition])\r\n\r\ns1 = State.create(name='s1')\r\ns2a = State.create(name='s2-a')\r\ns2b = State.create(name='s2-b')\r\ns3 = State.create(name='s3')\r\nTransition.create(source_state=s1, target_state=s2a)\r\nTransition.create(source_state=s1, target_state=s2b)\r\nTransition.create(source_state=s2a, target_state=s3)\r\nTransition.create(source_state=s2b, target_state=s3)\r\n\r\nquery = State.select().where(State.name != 's3')\r\ntransitions = Transition.select()\r\np = prefetch(query, transitions, prefetch_type=PREFETCH_TYPE.JOIN)\r\nfor row in p:\r\n print(row.name, row.sources, row.targets)\r\n```\r\n\r\nOutput as expected:\r\n\r\n```\r\ns1 [<Transition: s1->s2-a>, <Transition: s1->s2-b>] []\r\ns2-a [<Transition: s2-a->s3>] [<Transition: s1->s2-a>]\r\ns2-b [<Transition: s2-b->s3>] [<Transition: s1->s2-b>]\r\n```", "The above code also gives an error:\r\n```\r\npsycopg2.errors.AmbiguousColumn: column reference \"id\" is ambiguous\r\nLINE 1: ...AS \"t2\" WHERE (\"t2\".\"name\" != 's3')) AS \"t3\" ON ((\"t3\".\"id\" ...\r\n ^\r\n```\r\nQuery:\r\n```\r\n('SELECT DISTINCT \"t1\".\"id\", \"t1\".\"source_state_id\", \"t1\".\"target_state_id\" FROM \"transition\" AS \"t1\"\r\n INNER JOIN (SELECT \"t2\".\"id\", \"t2\".\"id\" FROM \"state\" AS \"t2\" WHERE (\"t2\".\"name\" != %s)) AS \"t3\"\r\n ON ((\"t3\".\"id\" = \"t1\".\"source_state_id\") OR (\"t3\".\"id\" = \"t1\".\"target_state_id\"))', ['s3'])\r\n```\r\nСhecked on the latest version 3.16.0. \r\nDatabase - PostgreSQL 10.23", "Oh no, I tested with SQLite so I assumed it was ok. Reopening and will look into it, thanks for letting me know.", "This is now fixed, thanks again." ]
"2023-03-10T13:06:12"
"2023-03-12T14:15:30"
"2023-03-12T14:08:10"
NONE
null
Hello! I'm have 2 models: ``` class State(Entity): uuid = UUIDField(column_name='uuid', primary_key=True) class Transition(Entity): uuid = UUIDField(column_name='uuid', primary_key=True) source_state = ForeignKeyField(State, column_name='source_state_id', backref='_db_source_transitions') target_state = ForeignKeyField(State, column_name='target_state_id', backref='_db_target_transitions') ``` I'm trying load `State` entity and all his `Transition`: ``` states = State.select().where(...) transitions = Transition.select() states = prefetch(states, transitions, prefetch_type=PREFETCH_TYPE.JOIN) ``` I get the following query: ``` SELECT ... FROM "transition" AS "t1" INNER JOIN (SELECT "t2"."uuid", "t2"."uuid" FROM "state" AS "t2" WHERE (...)) AS "t3" ON (("t3"."uuid" = "t1"."source_state_id") OR ("t3"."uuid" = "t1"."target_state_id")) ``` and error in ON statement: ``` column reference "uuid" is ambiguous ``` Is there a way to specify the single foreign key used or is it a bug?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/2690/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/2690/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/2689
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/2689/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/2689/comments
https://api.github.com/repos/coleifer/peewee/issues/2689/events
https://github.com/coleifer/peewee/issues/2689
1,617,001,747
I_kwDOAA7yGM5gYX0T
2,689
Is it possible to serialise peewee.Expression?
{ "login": "vdytyniak-exos", "id": 94358054, "node_id": "U_kgDOBZ_KJg", "avatar_url": "https://avatars.githubusercontent.com/u/94358054?v=4", "gravatar_id": "", "url": "https://api.github.com/users/vdytyniak-exos", "html_url": "https://github.com/vdytyniak-exos", "followers_url": "https://api.github.com/users/vdytyniak-exos/followers", "following_url": "https://api.github.com/users/vdytyniak-exos/following{/other_user}", "gists_url": "https://api.github.com/users/vdytyniak-exos/gists{/gist_id}", "starred_url": "https://api.github.com/users/vdytyniak-exos/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/vdytyniak-exos/subscriptions", "organizations_url": "https://api.github.com/users/vdytyniak-exos/orgs", "repos_url": "https://api.github.com/users/vdytyniak-exos/repos", "events_url": "https://api.github.com/users/vdytyniak-exos/events{/privacy}", "received_events_url": "https://api.github.com/users/vdytyniak-exos/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "No, not really or not officially. You can see how the [dynamic filters work in flask-peewee](http://docs.peewee-orm.com/projects/flask-peewee/en/latest/admin.html#filters): https://github.com/coleifer/flask-peewee/blob/master/flask_peewee/filters.py\r\n\r\nProbably the easiest thing to do though is to use the django-style query apis, eg `field__eq=value`. These can be passed to `model.filter()` like Django.\r\n\r\nLastly, we have irc on libera #peewee, or you can ask general questions on stack overflow. I regularly check SO and try to provide help there just fyi.", "@coleifer Thanks for you answer. I am trying to implement my own json decoder, looks like it is that hard to represent pewee.Expression tree in json. " ]
"2023-03-09T11:19:40"
"2023-03-09T14:04:47"
"2023-03-09T12:43:27"
NONE
null
it is not an issue, but I didn't find other communication channel to get some ideas in how to serialise peewee.Expression to pass it to the API and later use there as filter in the query. Thanks
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/2689/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/2689/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/2688
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/2688/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/2688/comments
https://api.github.com/repos/coleifer/peewee/issues/2688/events
https://github.com/coleifer/peewee/pull/2688
1,611,011,168
PR_kwDOAA7yGM5LWNxs
2,688
mysql add column comment
{ "login": "smzhao", "id": 2282742, "node_id": "MDQ6VXNlcjIyODI3NDI=", "avatar_url": "https://avatars.githubusercontent.com/u/2282742?v=4", "gravatar_id": "", "url": "https://api.github.com/users/smzhao", "html_url": "https://github.com/smzhao", "followers_url": "https://api.github.com/users/smzhao/followers", "following_url": "https://api.github.com/users/smzhao/following{/other_user}", "gists_url": "https://api.github.com/users/smzhao/gists{/gist_id}", "starred_url": "https://api.github.com/users/smzhao/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/smzhao/subscriptions", "organizations_url": "https://api.github.com/users/smzhao/orgs", "repos_url": "https://api.github.com/users/smzhao/repos", "events_url": "https://api.github.com/users/smzhao/events{/privacy}", "received_events_url": "https://api.github.com/users/smzhao/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Going to pass." ]
"2023-03-06T09:33:38"
"2023-03-06T12:16:44"
"2023-03-06T12:16:44"
NONE
null
mysql add column comment with verbose_name or help_text
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/2688/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/2688/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/2688", "html_url": "https://github.com/coleifer/peewee/pull/2688", "diff_url": "https://github.com/coleifer/peewee/pull/2688.diff", "patch_url": "https://github.com/coleifer/peewee/pull/2688.patch", "merged_at": null }
https://api.github.com/repos/coleifer/peewee/issues/2687
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/2687/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/2687/comments
https://api.github.com/repos/coleifer/peewee/issues/2687/events
https://github.com/coleifer/peewee/issues/2687
1,610,105,140
I_kwDOAA7yGM5f-EE0
2,687
`playhouse.signals.Signal.disconnect` disconnects more than key, sender pair.
{ "login": "real-yfprojects", "id": 62463991, "node_id": "MDQ6VXNlcjYyNDYzOTkx", "avatar_url": "https://avatars.githubusercontent.com/u/62463991?v=4", "gravatar_id": "", "url": "https://api.github.com/users/real-yfprojects", "html_url": "https://github.com/real-yfprojects", "followers_url": "https://api.github.com/users/real-yfprojects/followers", "following_url": "https://api.github.com/users/real-yfprojects/following{/other_user}", "gists_url": "https://api.github.com/users/real-yfprojects/gists{/gist_id}", "starred_url": "https://api.github.com/users/real-yfprojects/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/real-yfprojects/subscriptions", "organizations_url": "https://api.github.com/users/real-yfprojects/orgs", "repos_url": "https://api.github.com/users/real-yfprojects/repos", "events_url": "https://api.github.com/users/real-yfprojects/events{/privacy}", "received_events_url": "https://api.github.com/users/real-yfprojects/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Oh yes it should be instead:\r\n\r\n```\r\nif not (n,s)==key\r\n```", "Nice! Thanks for fixing. Do you have a rough estimate for the next release date?", "Let me think on it." ]
"2023-03-05T08:30:29"
"2023-03-05T14:57:19"
"2023-03-05T14:49:03"
NONE
null
When connecting two receiver to the same sender and disconnecting one of them. Both are disconnected. This bug is also illustrated by the code itself: https://github.com/coleifer/peewee/blob/f88fa44a29601ca2de9fe492fda11b1fb28fb412/playhouse/signals.py#L25-L38 The `_receivers` set stores pairs of receiver and model. When disconnecting a single pair is removed if present. However `_receiver_list` looses all entries for which `n != name and s != sender` is false. Quick transformation: $$ \lnot( n \ne name \land s \ne sender ) \Leftrightarrow $$ $$ \lnot( n \ne name ) \lor \lnot( s \ne sender ) \Leftrightarrow $$ $$ n = name \lor s = sender $$ Notice that all receivers are removed that have a matching name or receiver.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/2687/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/2687/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/2686
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/2686/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/2686/comments
https://api.github.com/repos/coleifer/peewee/issues/2686/events
https://github.com/coleifer/peewee/issues/2686
1,610,098,096
I_kwDOAA7yGM5f-CWw
2,686
Undocumented parameter `sender` for `playhouse.signals.Signal.disconnect`.
{ "login": "real-yfprojects", "id": 62463991, "node_id": "MDQ6VXNlcjYyNDYzOTkx", "avatar_url": "https://avatars.githubusercontent.com/u/62463991?v=4", "gravatar_id": "", "url": "https://api.github.com/users/real-yfprojects", "html_url": "https://github.com/real-yfprojects", "followers_url": "https://api.github.com/users/real-yfprojects/followers", "following_url": "https://api.github.com/users/real-yfprojects/following{/other_user}", "gists_url": "https://api.github.com/users/real-yfprojects/gists{/gist_id}", "starred_url": "https://api.github.com/users/real-yfprojects/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/real-yfprojects/subscriptions", "organizations_url": "https://api.github.com/users/real-yfprojects/orgs", "repos_url": "https://api.github.com/users/real-yfprojects/repos", "events_url": "https://api.github.com/users/real-yfprojects/events{/privacy}", "received_events_url": "https://api.github.com/users/real-yfprojects/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "You just don't want to update/improve the documentation of your library or why are you closing it without a comment. Others will find that pretty unwelcoming.", "7246a7f2b8c5adbae33180af3c817601560dc33a" ]
"2023-03-05T08:03:44"
"2023-03-05T16:53:34"
"2023-03-05T12:25:53"
NONE
null
https://github.com/coleifer/peewee/blob/f88fa44a29601ca2de9fe492fda11b1fb28fb412/playhouse/signals.py#L25 There is a `sender` parameter. However there is no such parameter here: https://github.com/coleifer/peewee/blob/f88fa44a29601ca2de9fe492fda11b1fb28fb412/docs/peewee/playhouse.rst?plain=1#L2740
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/2686/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/2686/timeline
null
not_planned
null
null
https://api.github.com/repos/coleifer/peewee/issues/2685
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/2685/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/2685/comments
https://api.github.com/repos/coleifer/peewee/issues/2685/events
https://github.com/coleifer/peewee/issues/2685
1,609,389,010
I_kwDOAA7yGM5f7VPS
2,685
Cast Bigint to timestamp
{ "login": "antoinebrtd", "id": 34452191, "node_id": "MDQ6VXNlcjM0NDUyMTkx", "avatar_url": "https://avatars.githubusercontent.com/u/34452191?v=4", "gravatar_id": "", "url": "https://api.github.com/users/antoinebrtd", "html_url": "https://github.com/antoinebrtd", "followers_url": "https://api.github.com/users/antoinebrtd/followers", "following_url": "https://api.github.com/users/antoinebrtd/following{/other_user}", "gists_url": "https://api.github.com/users/antoinebrtd/gists{/gist_id}", "starred_url": "https://api.github.com/users/antoinebrtd/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/antoinebrtd/subscriptions", "organizations_url": "https://api.github.com/users/antoinebrtd/orgs", "repos_url": "https://api.github.com/users/antoinebrtd/repos", "events_url": "https://api.github.com/users/antoinebrtd/events{/privacy}", "received_events_url": "https://api.github.com/users/antoinebrtd/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Is there a very compelling reason why you are using `TimestampField` at all, instead of `DateTimeField`? It's really intended mostly for Sqlite users, which does not provide a dedicated date/time type.\r\n\r\nAt any rate, you need to use the postgres `to_timestamp` function here if you insist on doing it this way:\r\n\r\n```sql\r\nselect extract(week from to_timestamp(1677887000));\r\n```\r\n\r\nSo probably something like (untested):\r\n\r\n```python\r\n.group_by(fn.date_part('week', fn.to_timestamp(Game.ts_played)))\r\n```" ]
"2023-03-03T23:16:36"
"2023-03-03T23:56:30"
"2023-03-03T23:56:29"
NONE
null
Hello, I am trying to partition some data using `fn.date_part` on a `TimestampField`. Here is my simplified model: ``` class Game(Model): id = PrimaryKeyField() ts_played = TimestampField(utc=True, default=None, null=True) score = IntegerField(null=True) ``` My full query: ``` results = Game \ .select( fn.date_part("week", Game.ts_played).alias("week"), fn.SUM(Game.score).alias("total_score") ) \ .where( Game.ts_played.is_null(False), Game.score.is_null(False), Game.ts_played >= 123456789, Game.ts_played <= 987654321 ) \ .group_by(fn.date_part("week", Game.ts_played)) \ .order_by(fn.date_part("week", Game.ts_played)) ``` I get the following error: ``` peewee.ProgrammingError: function date_part(unknown, bigint) does not exist ``` which does not surprise me because TimestampField is not really a timestamp but rather a Bigint. I then try to cast the underlying bigint to timestamp, replacing `Game.ts_played` everywhere in the query above with: ``` Game.ts_played.cast("timestamp") ``` I get the error ``` peewee.ProgrammingError: cannot cast type bigint to timestamp without time zone ``` It works fine without casting when I change `ts_played` to be a `DateTimeField`. Is there a convenient way to partition a `TimestampField` in weeks?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/2685/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/2685/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/2684
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/2684/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/2684/comments
https://api.github.com/repos/coleifer/peewee/issues/2684/events
https://github.com/coleifer/peewee/issues/2684
1,601,653,522
I_kwDOAA7yGM5fd0sS
2,684
Build failures with Cython 3.0.0b1
{ "login": "mgorny", "id": 110765, "node_id": "MDQ6VXNlcjExMDc2NQ==", "avatar_url": "https://avatars.githubusercontent.com/u/110765?v=4", "gravatar_id": "", "url": "https://api.github.com/users/mgorny", "html_url": "https://github.com/mgorny", "followers_url": "https://api.github.com/users/mgorny/followers", "following_url": "https://api.github.com/users/mgorny/following{/other_user}", "gists_url": "https://api.github.com/users/mgorny/gists{/gist_id}", "starred_url": "https://api.github.com/users/mgorny/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/mgorny/subscriptions", "organizations_url": "https://api.github.com/users/mgorny/orgs", "repos_url": "https://api.github.com/users/mgorny/repos", "events_url": "https://api.github.com/users/mgorny/events{/privacy}", "received_events_url": "https://api.github.com/users/mgorny/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Thank you, I think I got 'em in the above commit.", "Thanks, seems to build now. Note that there's still this warning though:\r\n\r\n```\r\n[1/2] Cythonizing playhouse/_sqlite_ext.pyx\r\n/tmp/peewee/venv/lib/python3.11/site-packages/Cython/Compiler/Main.py:370: FutureWarning: Cython directive 'language_level' not set, using '3str' for now (Py3). This has changed from earlier releases! File: /tmp/peewee/playhouse/_sqlite_ext.pyx\r\n tree = Parsing.p_module(s, pxd, full_module_name)\r\n[2/2] Cythonizing playhouse/_sqlite_udf.pyx\r\n/tmp/peewee/venv/lib/python3.11/site-packages/Cython/Compiler/Main.py:370: FutureWarning: Cython directive 'language_level' not set, using '3str' for now (Py3). This has changed from earlier releases! File: /tmp/peewee/playhouse/_sqlite_udf.pyx\r\n tree = Parsing.p_module(s, pxd, full_module_name)\r\n```", "Yeah I'm going to have to spend some time understanding the ramifications of setting the lang level directive. It should probably just be 3 but like I said, not sure the ramifications of that yet and tests are passing so I'll plan on keeping an eye on it." ]
"2023-02-27T17:48:43"
"2023-02-27T18:05:46"
"2023-02-27T17:57:56"
NONE
null
Cython 3.0.0 has released its first beta, meaning that 3.0.0 final will be out sooner than later. Right now peewee fails to build with it: ``` $ python setup.py build Compiling playhouse/_sqlite_udf.pyx because it changed. Compiling playhouse/_sqlite_ext.pyx because it changed. [1/2] Cythonizing playhouse/_sqlite_ext.pyx /tmp/peewee/venv/lib/python3.11/site-packages/Cython/Compiler/Main.py:370: FutureWarning: Cython directive 'language_level' not set, using '3str' for now (Py3). This has changed from earlier releases! File: /tmp/peewee/playhouse/_sqlite_ext.pyx tree = Parsing.p_module(s, pxd, full_module_name) Error compiling Cython file: ------------------------------------------------------------ ... pIdxInfo.estimatedCost = <double>1 pIdxInfo.estimatedRows = 10 else: # Penalize score based on number of missing params. pIdxInfo.estimatedCost = <double>10000000000000 * <double>(nParams - nArg) pIdxInfo.estimatedRows = 10 ** (nParams - nArg) ^ ------------------------------------------------------------ playhouse/_sqlite_ext.pyx:608:40: Cannot assign type 'double' to 'sqlite3_int64' Error compiling Cython file: ------------------------------------------------------------ ... self._commit_hook = fn if fn is None: sqlite3_commit_hook(self.conn.db, NULL, NULL) else: sqlite3_commit_hook(self.conn.db, _commit_callback, <void *>fn) ^ ------------------------------------------------------------ playhouse/_sqlite_ext.pyx:1463:46: Cannot assign type 'int (void *) except? -1 nogil' to 'int (*)(void *) noexcept nogil' Error compiling Cython file: ------------------------------------------------------------ ... self._rollback_hook = fn if fn is None: sqlite3_rollback_hook(self.conn.db, NULL, NULL) else: sqlite3_rollback_hook(self.conn.db, _rollback_callback, <void *>fn) ^ ------------------------------------------------------------ playhouse/_sqlite_ext.pyx:1473:48: Cannot assign type 'void (void *) except * nogil' to 'void (*)(void *) noexcept nogil' Error compiling Cython file: ------------------------------------------------------------ ... self._update_hook = fn if fn is None: sqlite3_update_hook(self.conn.db, NULL, NULL) else: sqlite3_update_hook(self.conn.db, _update_callback, <void *>fn) ^ ------------------------------------------------------------ playhouse/_sqlite_ext.pyx:1483:46: Cannot assign type 'void (void *, int, const char *, const char *, sqlite3_int64) except * nogil' to 'void (*)(void *, int, char *, char *, sqlite3_int64) noexcept nogil' Error compiling Cython file: ------------------------------------------------------------ ... """ if not self.conn.initialized or not self.conn.db: return False cdef sqlite3_int64 n = timeout * 1000 sqlite3_busy_handler(self.conn.db, _aggressive_busy_handler, <void *>n) ^ ------------------------------------------------------------ playhouse/_sqlite_ext.pyx:1494:43: Cannot assign type 'int (void *, int) except? -1 nogil' to 'int (*)(void *, int) noexcept nogil' Traceback (most recent call last): File "/tmp/peewee/setup.py", line 185, in <module> _do_setup(extension_support, sqlite_extension_support) File "/tmp/peewee/setup.py", line 180, in _do_setup ext_modules=cythonize(ext_modules)) ^^^^^^^^^^^^^^^^^^^^^^ File "/tmp/peewee/venv/lib/python3.11/site-packages/Cython/Build/Dependencies.py", line 1134, in cythonize cythonize_one(*args) File "/tmp/peewee/venv/lib/python3.11/site-packages/Cython/Build/Dependencies.py", line 1301, in cythonize_one raise CompileError(None, pyx_file) Cython.Compiler.Errors.CompileError: playhouse/_sqlite_ext.pyx ``` To reproduce: ``` pip install Cython==3.0.0b1 python setup.py build ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/2684/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/2684/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/2683
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/2683/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/2683/comments
https://api.github.com/repos/coleifer/peewee/issues/2683/events
https://github.com/coleifer/peewee/issues/2683
1,599,887,876
I_kwDOAA7yGM5fXFoE
2,683
Can't query with unicode character
{ "login": "groggyegg", "id": 66879210, "node_id": "MDQ6VXNlcjY2ODc5MjEw", "avatar_url": "https://avatars.githubusercontent.com/u/66879210?v=4", "gravatar_id": "", "url": "https://api.github.com/users/groggyegg", "html_url": "https://github.com/groggyegg", "followers_url": "https://api.github.com/users/groggyegg/followers", "following_url": "https://api.github.com/users/groggyegg/following{/other_user}", "gists_url": "https://api.github.com/users/groggyegg/gists{/gist_id}", "starred_url": "https://api.github.com/users/groggyegg/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/groggyegg/subscriptions", "organizations_url": "https://api.github.com/users/groggyegg/orgs", "repos_url": "https://api.github.com/users/groggyegg/repos", "events_url": "https://api.github.com/users/groggyegg/events{/privacy}", "received_events_url": "https://api.github.com/users/groggyegg/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "This probably has to do with the collation you're using. Is this MySQL?", "No, I’m using SQLite", "Wait so your data is *literally* the Unicode escapes? If so have you tried double escaping the forward quote?", "> Wait so your data is _literally_ the Unicode escapes? If so have you tried double escaping the forward quote?\r\n\r\nThat seems to fix the problem. I'm suprised that I didn't realized that :astonished:\r\nThanks!" ]
"2023-02-26T00:49:33"
"2023-02-26T12:53:07"
"2023-02-26T12:53:07"
NONE
null
I have a column containing this type of data `{"zh": "\u65e5\u97e9\u5267"}` and when I query it with this code `Video.select().where(Video.director.contains('\u65e5\u97e9\u5267'))` , I'm not getting any result. It only works when I query non-unicode text e.g. `Video.select().where(Video.director.contains('"zh"'))`.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/2683/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/2683/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/2682
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/2682/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/2682/comments
https://api.github.com/repos/coleifer/peewee/issues/2682/events
https://github.com/coleifer/peewee/issues/2682
1,599,859,949
I_kwDOAA7yGM5fW-zt
2,682
peewee.InterfaceError: Error, database must be initialized before opening a connection.
{ "login": "NPZYMR", "id": 101792221, "node_id": "U_kgDOBhE53Q", "avatar_url": "https://avatars.githubusercontent.com/u/101792221?v=4", "gravatar_id": "", "url": "https://api.github.com/users/NPZYMR", "html_url": "https://github.com/NPZYMR", "followers_url": "https://api.github.com/users/NPZYMR/followers", "following_url": "https://api.github.com/users/NPZYMR/following{/other_user}", "gists_url": "https://api.github.com/users/NPZYMR/gists{/gist_id}", "starred_url": "https://api.github.com/users/NPZYMR/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/NPZYMR/subscriptions", "organizations_url": "https://api.github.com/users/NPZYMR/orgs", "repos_url": "https://api.github.com/users/NPZYMR/repos", "events_url": "https://api.github.com/users/NPZYMR/events{/privacy}", "received_events_url": "https://api.github.com/users/NPZYMR/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "If you had taken a moment to debug this, you would have found that `db_name = os.environ.get('DB_NAME')` is somehow getting set to `None`. This is the issue.", "In debug, I'm getting my DB name in \"db_name = os.environ.get('DB_NAME')\" but\ndon't know how to rectify this now. please don't mind this I'm new to\nprogramming might sound silly.\n\nOn Sun, Feb 26, 2023 at 4:13 AM Charles Leifer ***@***.***>\nwrote:\n\n> If you had taken a moment to debug this, you would have found that db_name\n> = os.environ.get('DB_NAME') is somehow getting set to None. This is the\n> issue.\n>\n> —\n> Reply to this email directly, view it on GitHub\n> <https://github.com/coleifer/peewee/issues/2682#issuecomment-1445220548>,\n> or unsubscribe\n> <https://github.com/notifications/unsubscribe-auth/AYITTXNG2NCYUIK3EDA2Y3TWZKDHNANCNFSM6AAAAAAVIC6EQA>\n> .\n> You are receiving this because you authored the thread.Message ID:\n> ***@***.***>\n>\n\n-- \n============================================================================\nIMPORTANT NOTICE: The information in this e-mail and any attached files is \nCONFIDENTIAL and may be legally privileged or prohibited from disclosure \nand unauthorised use. The views of the author may not necessarily reflect \nthose of Zymr, Inc. It is intended solely for the addressee, or the \nemployee or agent responsible for delivering such materials to the \naddressee. If you have received this message in error please return it to \nthe sender then delete the email and destroy any copies of it. If you are \nnot the intended recipient, any form of reproduction, dissemination, \ncopying, disclosure, modification, distribution and/or publication, or any \naction taken or omitted to be taken in reliance upon this message or its \nattachments is prohibited and may be unlawful. At present the integrity of \ne-mail across the Internet cannot be guaranteed and messages sent via this \nmedium are potentially at risk. All liability is excluded to the extent \npermitted by law for any claims arising as a result of the use of this \nmedium to transmit information by or to Zymr, Inc.\n", "You would want to double-check what you're specifying wherever you have your `PostgresqlDatabase(...)` constructor, e.g.:\r\n\r\n```\r\nassert db_name, 'db_name is empty!'\r\npg_db = PostgresqlExtDatabase(db_name, user=db_user, password=db_password,host=db_host, port=db_port)\r\n```", "Thank you for your help, I'll check it out.\n\nOn Sun, Feb 26, 2023 at 4:27 AM Charles Leifer ***@***.***>\nwrote:\n\n> You would want to double-check what you're specifying wherever you have\n> your PostgresqlDatabase(...) constructor, e.g.:\n>\n> assert db_name, 'db_name is empty!'\n> pg_db = PostgresqlExtDatabase(db_name, user=db_user, password=db_password,host=db_host, port=db_port)\n>\n> —\n> Reply to this email directly, view it on GitHub\n> <https://github.com/coleifer/peewee/issues/2682#issuecomment-1445222329>,\n> or unsubscribe\n> <https://github.com/notifications/unsubscribe-auth/AYITTXMRJVQ5CQBNMEH2RDDWZKE3XANCNFSM6AAAAAAVIC6EQA>\n> .\n> You are receiving this because you authored the thread.Message ID:\n> ***@***.***>\n>\n\n-- \n============================================================================\nIMPORTANT NOTICE: The information in this e-mail and any attached files is \nCONFIDENTIAL and may be legally privileged or prohibited from disclosure \nand unauthorised use. The views of the author may not necessarily reflect \nthose of Zymr, Inc. It is intended solely for the addressee, or the \nemployee or agent responsible for delivering such materials to the \naddressee. If you have received this message in error please return it to \nthe sender then delete the email and destroy any copies of it. If you are \nnot the intended recipient, any form of reproduction, dissemination, \ncopying, disclosure, modification, distribution and/or publication, or any \naction taken or omitted to be taken in reliance upon this message or its \nattachments is prohibited and may be unlawful. At present the integrity of \ne-mail across the Internet cannot be guaranteed and messages sent via this \nmedium are potentially at risk. All liability is excluded to the extent \npermitted by law for any claims arising as a result of the use of this \nmedium to transmit information by or to Zymr, Inc.\n", "After migration do I need to remove migrate(.... ) function from my model\nfile?\n\nHow will I add new model field in my existing model class(python code)?\n\n-- \n============================================================================\nIMPORTANT NOTICE: The information in this e-mail and any attached files is \nCONFIDENTIAL and may be legally privileged or prohibited from disclosure \nand unauthorised use. The views of the author may not necessarily reflect \nthose of Zymr, Inc. It is intended solely for the addressee, or the \nemployee or agent responsible for delivering such materials to the \naddressee. If you have received this message in error please return it to \nthe sender then delete the email and destroy any copies of it. If you are \nnot the intended recipient, any form of reproduction, dissemination, \ncopying, disclosure, modification, distribution and/or publication, or any \naction taken or omitted to be taken in reliance upon this message or its \nattachments is prohibited and may be unlawful. At present the integrity of \ne-mail across the Internet cannot be guaranteed and messages sent via this \nmedium are potentially at risk. All liability is excluded to the extent \npermitted by law for any claims arising as a result of the use of this \nmedium to transmit information by or to Zymr, Inc.\n", "```class User(Model):\n pass\n\nf = TextField()\nUser._meta.add_field('username', f)\nprint(User._meta.fields)# {'id': <peewee.AutoField at\n0x7f552815bc50>,# 'username': <peewee.TextField at 0x7f552b1d7e10>}\n```\n\n\nI've read one reply of yours in which you are referring to this. Is\nthat referring to what I want.\n\n\nOn Mon, Feb 27, 2023 at 1:07 AM Naveen Pandia ***@***.***>\nwrote:\n\n> After migration do I need to remove migrate(.... ) function from my model\n> file?\n>\n> How will I add new model field in my existing model class(python code)?\n>\n\n-- \n============================================================================\nIMPORTANT NOTICE: The information in this e-mail and any attached files is \nCONFIDENTIAL and may be legally privileged or prohibited from disclosure \nand unauthorised use. The views of the author may not necessarily reflect \nthose of Zymr, Inc. It is intended solely for the addressee, or the \nemployee or agent responsible for delivering such materials to the \naddressee. If you have received this message in error please return it to \nthe sender then delete the email and destroy any copies of it. If you are \nnot the intended recipient, any form of reproduction, dissemination, \ncopying, disclosure, modification, distribution and/or publication, or any \naction taken or omitted to be taken in reliance upon this message or its \nattachments is prohibited and may be unlawful. At present the integrity of \ne-mail across the Internet cannot be guaranteed and messages sent via this \nmedium are potentially at risk. All liability is excluded to the extent \npermitted by law for any claims arising as a result of the use of this \nmedium to transmit information by or to Zymr, Inc.\n" ]
"2023-02-25T22:25:31"
"2023-02-26T19:46:52"
"2023-02-25T22:42:51"
NONE
null
import os from playhouse.postgres_ext import CharField, DateTimeField, IntegerField, BooleanField from .base import Base import datetime from peewee import PostgresqlDatabase from playhouse.migrate import * db_name = os.environ.get('DB_NAME') db_host = os.environ.get('DB_HOST') db_port = os.environ.get('DB_PORT') db_password = os.environ.get('DB_PASSWORD') db_user= os.environ.get('DB_USER') # Initialize database. pg_db = PostgresqlExtDatabase(db_name, user=db_user, password=db_password,host=db_host, port=db_port) migrator = PostgresqlMigrator(pg_db) class EmpDetails(Base): id = CharField(25, null=False) email = CharField(255, unique=True) name = CharField(255) location = CharField(255) created_at = DateTimeField(default=datetime.datetime.now) updated_at = DateTimeField(default=datetime.datetime.now) is_active = BooleanField(default=True) role = CharField(25) class Meta: table_name = 'emp_details' test_field = CharField(default='') migrate( migrator.add_column('emp_details', 'test', test_field), ) I'm trying to make my DB instance for migration but getting an error : ``` File "/home/naveen.p@ah.zymrinc.com/Desktop/zfr/server/s-venv/lib/python3.8/site-packages/peewee.py", line 3026, in connect raise InterfaceError('Error, database must be initialized ' peewee.InterfaceError: Error, database must be initialized before opening a connection. ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/2682/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/2682/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/2681
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/2681/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/2681/comments
https://api.github.com/repos/coleifer/peewee/issues/2681/events
https://github.com/coleifer/peewee/issues/2681
1,599,322,496
I_kwDOAA7yGM5fU7mA
2,681
Does migrate() run every time I run server(Ex. flask server)
{ "login": "NPZYMR", "id": 101792221, "node_id": "U_kgDOBhE53Q", "avatar_url": "https://avatars.githubusercontent.com/u/101792221?v=4", "gravatar_id": "", "url": "https://api.github.com/users/NPZYMR", "html_url": "https://github.com/NPZYMR", "followers_url": "https://api.github.com/users/NPZYMR/followers", "following_url": "https://api.github.com/users/NPZYMR/following{/other_user}", "gists_url": "https://api.github.com/users/NPZYMR/gists{/gist_id}", "starred_url": "https://api.github.com/users/NPZYMR/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/NPZYMR/subscriptions", "organizations_url": "https://api.github.com/users/NPZYMR/orgs", "repos_url": "https://api.github.com/users/NPZYMR/repos", "events_url": "https://api.github.com/users/NPZYMR/events{/privacy}", "received_events_url": "https://api.github.com/users/NPZYMR/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Let's say you want to add a column to a model in an application. The typical process would be to:\r\n\r\n1. Stop the application.\r\n2. Update the schema of the database by running a migration once.\r\n3. Restart the application with the new field present in the code.\r\n\r\nYou can always add a \"check\" in your `create_...()` function to see if the column exists, and if not, do the migration. This would only be necessary if you have lots of instances of your application running around which will be updated at some unknown time, e.g., this is a library or something.", "> Let's say you want to add a column to a model in an application. The typical process would be to:\r\n> \r\n> 1. Stop the application.\r\n> 2. Update the schema of the database by running a migration once.\r\n> 3. Restart the application with the new field present in the code.\r\n> \r\n> You can always add a \"check\" in your `create_...()` function to see if the column exists, and if not, do the migration. This would only be necessary if you have lots of instances of your application running around which will be updated at some unknown time, e.g., this is a library or something.\r\n\r\n\r\nI want to make sure that the Production env runs smoothly as whatever migrations I've written will be applied once, stopping production env won't be a good option very time.\r\n\r\nwhat you mentioned about the check I didn't get that properly.\r\n\r\nI'm calling create _table like this:\r\n\r\n```\r\ndef create_tables():\r\n \r\n EmpDetails.create_table(fail_silently=True)\r\n\r\nI'm going to add multiple models here\r\n```\r\n\r\nand calling this create_tables() at server start.\r\n\r\n\r\nSecondly, where to add that new column field (Question 1)?", "I think you are imagining you buy some security by doing it this way but you really do not. Schema changes are one-time operations. It's probably best to put them in standalone scripts and run them when you deploy application changes." ]
"2023-02-24T21:54:40"
"2023-02-25T12:46:39"
"2023-02-24T22:51:06"
NONE
null
Suppose I've added create_table(fail_silently=True) when the flask server starts. In this model class below, I want to add the column "test" in my DB corresponding field "test_field". Question: 1. Do I need to add "test_field" in my model **EmpDetails** or outside the **class** or both(like I did in the code snippet) for migrations? 2. As I've created create_function() to run at the server(flask server) start, will it migrate() every time at the start of the server(_I need to make sure whether data added in the new column will not vanish if migrate runs every time_). or if the schema changes are done in the database will it not rerun the migration? Code snippet for my model class: ``` class EmpDetails(Base): id = CharField(25, null=False) email = CharField(255, unique=True) name = CharField(255) location = CharField(255) created_at = DateTimeField(default=datetime.datetime.now) updated_at = DateTimeField(default=datetime.datetime.now) is_active = BooleanField(default=True) role = CharField(25) test_field = CharField(default='') -------> here class Meta: table_name = 'emp_details' test_field = CharField(default='') ---------> here migrate( migrator.add_column(EmpDetails._meta.emp_details, 'test', test_field), ) ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/2681/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/2681/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/2680
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/2680/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/2680/comments
https://api.github.com/repos/coleifer/peewee/issues/2680/events
https://github.com/coleifer/peewee/issues/2680
1,593,303,175
I_kwDOAA7yGM5e9-CH
2,680
How to use with pgbouncer?
{ "login": "backpropogation", "id": 34347364, "node_id": "MDQ6VXNlcjM0MzQ3MzY0", "avatar_url": "https://avatars.githubusercontent.com/u/34347364?v=4", "gravatar_id": "", "url": "https://api.github.com/users/backpropogation", "html_url": "https://github.com/backpropogation", "followers_url": "https://api.github.com/users/backpropogation/followers", "following_url": "https://api.github.com/users/backpropogation/following{/other_user}", "gists_url": "https://api.github.com/users/backpropogation/gists{/gist_id}", "starred_url": "https://api.github.com/users/backpropogation/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/backpropogation/subscriptions", "organizations_url": "https://api.github.com/users/backpropogation/orgs", "repos_url": "https://api.github.com/users/backpropogation/repos", "events_url": "https://api.github.com/users/backpropogation/events{/privacy}", "received_events_url": "https://api.github.com/users/backpropogation/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "They are somewhat orthogonal, and also dependent upon what kind of pooling you use in pgbouncer (session, txn or statement). Peewee's pooled variants will maintain open connections to postgres so doubling-up and using `PooledPostgresqlDatabase` + pgbouncer is probably unnecessary. It also kinda depends on what latency you anticipate with opening the connection (whether to pg itself or to your pgbouncer). There \"right\" answer is: it depends.\r\n\r\nIf you use pgbouncer, though, a good starting place is just to use `PostgresqlDatabase` and point it at pgbouncer.\r\n\r\nIf you want to let peewee handle a connection pool, use the Pooled- variants." ]
"2023-02-21T11:23:00"
"2023-02-21T13:35:54"
"2023-02-21T13:35:54"
NONE
null
Could someone, please, make clear, how to use peewee with pgbouncer? Am I supposed to use `PooledPostgresqlExtDatabase` or it's overkill and just `PostgresqlExtDatabase` will be fine? Connection string will point to pgbouncer.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/2680/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/2680/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/2679
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/2679/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/2679/comments
https://api.github.com/repos/coleifer/peewee/issues/2679/events
https://github.com/coleifer/peewee/pull/2679
1,592,259,335
PR_kwDOAA7yGM5KXb30
2,679
Fix typo in docs
{ "login": "puntonim", "id": 6423485, "node_id": "MDQ6VXNlcjY0MjM0ODU=", "avatar_url": "https://avatars.githubusercontent.com/u/6423485?v=4", "gravatar_id": "", "url": "https://api.github.com/users/puntonim", "html_url": "https://github.com/puntonim", "followers_url": "https://api.github.com/users/puntonim/followers", "following_url": "https://api.github.com/users/puntonim/following{/other_user}", "gists_url": "https://api.github.com/users/puntonim/gists{/gist_id}", "starred_url": "https://api.github.com/users/puntonim/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/puntonim/subscriptions", "organizations_url": "https://api.github.com/users/puntonim/orgs", "repos_url": "https://api.github.com/users/puntonim/repos", "events_url": "https://api.github.com/users/puntonim/events{/privacy}", "received_events_url": "https://api.github.com/users/puntonim/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[]
"2023-02-20T17:54:34"
"2023-02-20T21:01:12"
"2023-02-20T21:01:12"
NONE
null
null
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/2679/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/2679/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/2679", "html_url": "https://github.com/coleifer/peewee/pull/2679", "diff_url": "https://github.com/coleifer/peewee/pull/2679.diff", "patch_url": "https://github.com/coleifer/peewee/pull/2679.patch", "merged_at": null }

Dataset Card for Peewee Issues

Dataset Summary

Peewee Issues is a dataset containing all the issues in the Peewee github repository up to the last date of extraction (5/3/2023). It has been made for educational purposes in mind (especifically, to get me used to using Hugging Face's datasets), but can be used for multi-label classification or semantic search. The contents are all in English and concern SQL databases and ORM libraries.

Downloads last month
0
Edit dataset card