- Fixed #94: Aggregated subquery bug fixed
- Fixed #18: Allow to specify
size
andunsigned
for int type - Fixed #77: Discriminate Pony-generated fields in entities: Attribute.is_implicit field added
- Fixed #83: Entity.get() should issue LIMIT 2 when non-unique criteria used for search
- Fixed #84: executing db.insert() should turn off autocommit and begin transaction
- Fixed #88: composite_index(*attrs) added to support non-unique composite indexes
- Fixed #89: IN / NOT IN clauses works different with empty sequence
- Fixed #90: Do not automatically add "distinct" if query.first() used
- Fixed #91: document automatic "distinct" behaviour and also .without_distinct()
- Fixed #92: without_distinct() and first() do not work together correctly
size
andunsigned
options forint
attributeslink
Since the long
type has gone in Python 3, the long
type is deprecated in Pony now. Instead of long
you should use the int
type and specify the size
option:
class MyEntity(db.Entity):
attr1 = Required(long) # deprecated
attr2 = Required(int, size=64) # new way for using BIGINT type in the database
- Fixes #81: python3.3: syntax error during installation in ubuntu 14.04
- Python 3 support
- pymysql adapter support for MySQL databases
Now Pony treats both str
and unicode
attribute types as they are unicode strings in both Python 2 and 3. So, the attribute declaration attr = Required(str)
is equal to attr = Required(unicode)
in Python 2 and 3. The same thing is with LongStr
and LongUnicode
- both of them are represented as unicode strings now.
For the sake of backward compatibility Pony adds unicode
as an alias to str
and buffer
as an alias to bytes
in Python 3.
- Fixes #74: Wrong FK column type when using sql_type on foreign ID column
- Fixes #75: MappingError for self-referenced entities in a many-to-many relationship
- Fixes #80: “Entity NoneType does not belong to database” when using to_dict
-
pony.orm.serialization
module with theto_dict()
andto_json()
functions was added. Before this release you could use theto_dict()
method of an entity instance in order to get a key-value dictionary structure for a specific entity instance. Sometimes you might need to serialize not only the instance itself, but also the instance's related objects. In this case you can use theto_dict()
function from the pony.orm.serialization module. -
Query.prefetch()
– allows to specify which related objects or attributes should be loaded from the database along with the query result . Example:
select(s for s in Student).prefetch(Group, Department, Student.courses)
-
obj.flush()
– allows flush a specific entity to the database -
obj.get_pk()
– return the primary key value for an entity instance -
py_check
parameter for attributes added. This parameter allows you to specify a function which will be used for checking the value before it is assigned to the attribute. The function should returnTrue
/False
or can raiseValueError
exception if the check failed. Example:
class Student(db.Entity):
name = Required(unicode)
gpa = Required(float, py_check=lambda val: val >= 0 and val <= 5)
time
andtimedelta
– now you can use these types for attribute declaration. Also you can usetimedelta
and a combination ofdatetime
+timedelta
types inside queries.
after_insert
,after_update
,after_delete
- these hooks are called when an object was inserted, updated or deleted in the database respectively (link)
- Added support for pymysql – pure Python MySQL client. Currently it is used as a fallback for MySQLdb interface
obj.order_by()
method is deprecated, useEntity.select().order_by()
insteadobj.describe()
now displays composite primary keys- Fixes #50: PonyORM does not escape _ and % in LIKE queries
- Fixes #51: Handling of one-to-one relations in declarative queries
- Fixes #52: An attribute without a column should not have rbits & wbits
- Fixes #53: Column generated at the wrong side of "one-to-one" relationship
- Fixes #55:
obj.to_dict()
should do flush at first if the session cache is modified - Fixes #57: Error in
to_dict()
when to-one attribute value is None - Fixes #70: EntitySet allows to add and remove None
- Check that the entity name starts with a capital letter and throw exception if it is not then raise the
ERDiagramError: Entity class name should start with a capital letter
exception
This release fixes the setup.py problem that was found after the previous release was uploaded to PyPI.
This release is a step forward to Python 3 support. While the external API wasn't changed, the internals were significantly refactored to provide forward compatibility with Python 3.
- New to_dict() method can be used to convert entity instance to dictionary. This method can be useful when you need to serialize an object to JSON or other format (link)
- Now select() function and filter() method of the query object can accept lambdas with closures
- Some minor bugs were fixed
Before this release, if a text attribute was defined without the max length specified (e.g. name = Required(unicode)
), Pony set the maximum length equal to 200 and used SQL type VARCHAR(200)
. Actually, PostgreSQL and SQLite do not require specifying the maximum length for strings. Starting with this release such text attributes are declared as TEXT
in SQLite and PostgreSQL. In these DBMSes, the TEXT
datatype has the same performance as VARCHAR(N)
and doesn't have arbitrary length restrictions.
For other DBMSes default varchar limit was increased up to 255 in MySQL and to 1000 in Oracle.
- Correct parsing of datetime values with T separator between date and time
- Entity.delete() bug fixed
- Lazy attribute loading bug fixed
- New transaction model (link)
- New method
Query.filter()
allows step-by-step query construction (link) - New method
Database.bind()
simplifies testing and allows using different settings for development and production (link) - New method
Query.page()
simplifies pagination (link) - New method
MyEntity.select_random(N)
is effective for large tables (link) - New method
Query.random(N)
for selecting random instances (link) - Support of new
concat()
function inside declarative queries - New
before_insert()
,before_update()
,before_delete()
entity instance hooks which can be overridden - Ability to specify
sequence_name='seq_name'
for PrimaryKey attributes for Oracle database - Ability to create new entity instances specifying the value of the primary key instead of the object
- Ability to read entity object attributes outside of the db_session
- Ability to use lambdas as a reference to an entity in relationship attribute declarations (link)
- The names of tables, indexes and constraints in the database creation script now are sorted in the alphabetical order
- In MySQL and PostgreSQL Pony converts the table names to the lower case. In Oracle – to the upper case. In SQLite leaves as is.
- The option
options.MAX_FETCH_COUNT
is set toNone
by default now - The support of PyGreSQL is discontinued, using psycopg2 instead
- Added
pony.__version__
attribute - Multiple bugs were fixed
- Stability and performance improvements
- Database
create_tables()
/drop_all_tables()
methods Database.drop_table(name)
,Entity.drop_table()
,Set.drop_table()
methodsDatabase.disconnect()
methods (allows SQLite files deletion after disconnection)- Pony now automatically enables foreign key checks in SQLite
Entity.exists(...)
method addeddistinct()
function added:select((s.group, sum(distinct(s.gpa))) for s in Student)
- Refactoring & bugfixes
- Use standard transaction mode by default instead of optimistic mode
SELECT ... FOR UPDATE
support added:select(...).for_update()[:]
UUID
datatype support added- Automatic foreign key indexes generation
- MySQL foreign key bug workaround added
- Check_tables parameter of
generate_mapping()
is deprecated - Bug fixes
@db_session
decorator is required for any database interaction;- support of pickling/unpickling (queries and objects can be stored in memcached);
- lazy collections - don't load all the items if only one is needed;
- datetime precision now can be specified;
- multiple bugs were fixed.