-
Notifications
You must be signed in to change notification settings - Fork 246
Description
Hello Ponyorm team! I am running into an interesting issue, and its one that I suspect I am just missing something on.
Below is a test python script to replicate what I am seeing, but basically I cannot perform date time comparisons with ponyorm. I get an exception (included below the snippet)
from datetime import datetime
from pony import orm
from pony.orm import Required, db_session
db = orm.Database()
class Foo(db.Entity):
insert_time = Required( datetime, default = datetime.now())
key = Required(str)
value = Required(str)
db.bind(provider = 'sqlite', filename = ':memory:')
db.generate_mapping(create_tables=True, check_tables=True)
with db_session:
f = Foo(key = "hello", value = "world")
a = Foo.select(lambda foo: foo.insert_time <= datetime.now())
print(a)
Traceback (most recent call last):
File "/tmp/test.py", line 18, in <module>
a = Foo.select(lambda foo: foo.insert_time <= datetime.now())
File "/home/miversen/git/spotify-playlist-exporter/venv/lib/python3.13/site-packages/pony/orm/core.py", line 4027, in select
if args: query = entity._query_from_args_(args, kwargs, frame_depth=cut_traceback_depth+1)
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/miversen/git/spotify-playlist-exporter/venv/lib/python3.13/site-packages/pony/orm/core.py", line 4401, in _query_from_args_
return Query(code_key, inner_expr, globals, locals, cells)
File "/home/miversen/git/spotify-playlist-exporter/venv/lib/python3.13/site-packages/pony/orm/core.py", line 5672, in __init__
tree, extractors = create_extractors(code_key, tree, globals, locals, special_functions, const_functions)
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/miversen/git/spotify-playlist-exporter/venv/lib/python3.13/site-packages/pony/orm/asttranslation.py", line 451, in create_extractors
src = node.src = ast2src(node)
~~~~~~~^^^^^^
File "/home/miversen/git/spotify-playlist-exporter/venv/lib/python3.13/site-packages/pony/orm/asttranslation.py", line 75, in ast2src
PythonTranslator(tree)
~~~~~~~~~~~~~~~~^^^^^^
File "/home/miversen/git/spotify-playlist-exporter/venv/lib/python3.13/site-packages/pony/orm/asttranslation.py", line 89, in __init__
translator.dispatch(tree)
~~~~~~~~~~~~~~~~~~~^^^^^^
File "/home/miversen/git/spotify-playlist-exporter/venv/lib/python3.13/site-packages/pony/orm/asttranslation.py", line 47, in dispatch
translator.call(post_method, node)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
File "/home/miversen/git/spotify-playlist-exporter/venv/lib/python3.13/site-packages/pony/orm/asttranslation.py", line 91, in call
node.src = method(translator, node)
~~~~~~^^^^^^^^^^^^^^^^^^
File "/home/miversen/git/spotify-playlist-exporter/venv/lib/python3.13/site-packages/pony/orm/asttranslation.py", line 220, in postCall
args = [ arg.src for arg in node.args ] + [ kw.src for kw in node.keywords ]
^^^^^^^
AttributeError: 'NoneType' object has no attribute 'src'
What am I missing here?
Note, I did try just using integers instead (as I was able to do that in sqlite directly, and as called out in their documentation, sqlite3 doesn't have a concept of datetime anyway), but trying to save seconds after epoch gave me a different error (saying my integer was too big), even after setting the maximum to 32 (the biggest sqlite allows I guess?) and making it unsigned.
Edit:
Some potentially useful information
Python Version: 3.13.1
OS: Arch Linux
Ponyorm version: 0.7.19