You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from pony.orm import *
db = Database('sqlite', ':memory:')
class Foo(db.Entity):
foo_id = PrimaryKey(int, auto=True)
name = Required(str)
def __repr__(self):
return "<Foo: %s>" %(self.name)
db.generate_mapping(create_tables=True)
def foo():
with db_session:
f = Foo(name="aaa")
f = Foo(name="aab")
f = Foo(name="abb")
f = Foo(name="abc")
search = "ab%"
results = select(
f for f in Foo
if raw_sql("name LIKE $(search)")
)
print list(results)
foo()
Results in:
pony.orm.core.ExprEvalError: (search) raises NameError: name 'search' is not defined
Even though search is in scope. Taking the function body out of the foo() function and executing it in the main body of the test script works fine.
The text was updated successfully, but these errors were encountered:
The documentation was moved from this repo to a separate one at https://github.com/ponyorm/pony-doc
The compiled version can be found at https://docs.ponyorm.com
# New features
* Python 3.5 support
* #132, #145: raw_sql() function was added
* #126: Ability to use @db_session with generator functions
* #116: Add support to select by UUID
* Ability to get string SQL statement using the Query.get_sql() method
* New function delete(gen) and Query.delete(bulk=False)
* Now it is possible to override Entity.__init__() and declare custom entity methods
# Backward incompatible changes
* Normalizing table names for symmetric relationships
* Autostrip - automatically remove leading and trailing characters
# Bugfixes
* #87: Pony fails with pymysql installed as MySQLdb
* #118: Pony should reconnect if previous connection was created before process was forked
* #121: Unable to update value of unique attribute
* #122: AssertionError when changing part of a composite key
* #127: a workaround for incorrect pysqlite locking behavior
* #136: Cascade delete does not work correctly for one-to-one relationships
* #141, #143: remove restriction on adding new methods to entities
* #142: Entity.select_random() AssertionError
* #147: Add 'atom_expr' symbol handling for Python 3.5 grammar
Test code:
Results in:
Even though
search
is in scope. Taking the function body out of thefoo()
function and executing it in the main body of the test script works fine.The text was updated successfully, but these errors were encountered: