Package: alchy
A SQLAlchemy extension for its declarative ORM that provides enhancements for model classes, queries, and sessions.MAINTENANCE MODEPROJECT IS IN MAINTENANCE MODE: NO NEW FEATURES, BUG FIXES ONLYUsesqlserviceinstead.LinksProject:https://github.com/dgilland/alchyDocumentation:https://alchy.readthedocs.ioPyPi:https://pypi.python.org/pypi/alchy/TravisCI:https://travis-ci.org/dgilland/alchyChangelogv2.2.2 (2017-01-03)Fix bug in handling of session options when providing explicitbindsvalue viasession_optionsduringManagerin initialization. Thanksbrianbruggeman!v2.2.1 (2016-05-18)Fix bug withevents.before_deletewhere decorator was defined using invalid parent class making it completely non-functional as a decorator.v2.2.0 (2016-03-21)Addmetadata``argumentto ``alchy.model.make_declarative_baseto provide custom metaclass for declarative base model. Thanksfabioramponi!v2.1.0 (2016-03-11)AddMetaargument toalchy.model.make_declarative_baseto provide custom metaclass for declarative base model. Thankselidchan!v2.0.1 (2015-07-29)MakeSession.get_bind()mapperargument have default value ofNone.v2.0.0 (2015-04-29)AddQuery.index_by.AddQuery.chain.Addpydashas dependency and incorporate into existingQuerymethods:map,reduce,reduce_right, andpluck.Improve logic for setting__tablename__to work with all table inheritance styles (joined, single, and concrete), to handle@declared_attrcolumns, and not to duplicate underscore characters. Thankssethp!Modify logic that sets a Model class’__table_args__and__mapper_args__(unless overridden in subclass) by merging__global_table_args__and__global_mapper_args__from all classes in the class’smro()with__local_table_args__and__local_mapper_args__from the class itself. A__{global,local}_{table,mapper}_args__may be callable or classmethod, in which case it is evaluated on the class whose__{table,mapper}_args__is being set. Thankssethp! (breaking change)v1.5.1 (2015-01-13)Add support for callable__table_args__and__local_table_args__. Thankssethp!v1.5.0 (2014-12-16)AddModel.is_modified(). Thankssethp!AddModel.filter().AddModel.filter_by().v1.4.2 (2014-11-18)Addsearch.inenumandsearch.notinenumfor performing anin_andnot(in_)comparision usingDeclarativeEnum.v1.4.1 (2014-11-17)AllowModel.__bind_key__to be set at the declarative base level so that model classes can properly inherit it.v1.4.0 (2014-11-09)MakeModelBase’s__table_args__and__mapper_args__inheritable via mixins. Thankssethp!Add__enum_args__toDeclarativeEnum. Thankssethp!Allow enum name to be overridden when callingDeclarativeEnum.db_type(). Thankssethp!v1.3.1 (2014-10-14)DuringModel.update()when setting a non-list relationship automatically instantiatedictvalues using the relationship model class.v1.3.0 (2014-10-10)Convert null relationships to{}when callingModel.to_dict()instead of leaving asNone.v1.2.0 (2014-10-10)DuringModel.update()when setting a list relationship automatically instantiatedictvalues using the relationship model class.v1.1.2 (2014-09-25)Allowaliaskeyword argument toQuery.join_eager()andQuery.outerjoin_eager()to be adictmapping aliases to join keys. Enables nested aliases.v1.1.1 (2014-09-01)Fix handling of nestedModel.update()calls to relationship attributes so that setting relationship to emptydictwill propagateNoneto relationship attribute value correctly.v1.1.0 (2014-08-30)Addquery.LoadOptionto support nesting load options when calling thequery.Queryload methods:join_eager,outerjoin_eager,joinedload,immediateload,lazyload,noload, andsubqueryload.v1.0.0 (2014-08-25)Replace usage of@classpropertydecorators inModelBasewith@classmethod. Any previously defined class properties now require method access. Affected attributes are:session,primary_key,primary_keys,primary_attrs,attrs,descriptors,relationships,column_attrs, andcolumns. (breaking change)Proxygetitemandsetitemaccess togetattrandsetattrinModelBase. Allows models to be accessed like dictionaries.Makealchy.eventsdecorators class based.Requirealchy.eventsdecorators to be instantiated using a function call (e.g.@events.before_update()instead of@events.before_update). (breaking change)Addalchy.searchcomparators,eqenumandnoteqenum, for comparingDeclarativeEnumtypes.v0.13.3 (2014-07-26)Fixutils.iterflatten()by callingiterflatten()instead offlattenin recursive loop.v0.13.2 (2014-06-12)AddModelBase.primary_attrsclass property that returns a list of class attributes that are primary keys.UseModelBase.primary_attrsinQueryModel.search()so that it handles cases where primary keys have column names that are different than the class attribute name.v0.13.1 (2014-06-11)Modify internals ofQueryModel.search()to better handle searching on a query object that already has joins and filters applied.v0.13.0 (2014-06-03)Addsearch.icontainsandsearch.noticontainsfor case insensitive contains filter.Remove strict update support fromModel.update(). Require this to be implemented in user-land. (breaking change)v0.12.0 (2014-05-18)Merge originating query where clause inQuery.searchso that pagination works properly.Addsession_classargument toManagerwhich can override the default session class used.v0.11.3 (2014-05-05)InModelMetawhen checking whether to do tablename autogeneration, tranverse all base classes when trying to determine if a primary key is defined.InModelMetasetbind_keyin__init__method instead of__new__. This also fixes an issue where__table_args__was incorrectly assumed to always be adict.v0.11.2 (2014-05-05)Supportorder_byas list/tuple inQueryModel.search().v0.11.1 (2014-05-05)Fix bug inQueryModel.search()whereorder_bywasn’t applied in the correct order. Needed to come before limit/offset are applied.v0.11.0 (2014-05-04)PEP8 compliance with default settings.Removequery_propertyargument frommake_declarative_base()andextend_declarative_base(). (breaking change)AddModelBase.primary_keysclass property which returns a tuple always (ModelBase.primary_keyreturns a single key if only one present or a tuple if multiple).Move location of classQueryPropertyfromalchy.modeltoalchy.query. (breaking change)Create newQuerysubclass namedQueryModelwhich is to be used within a query property context. ReplaceQuerywithQueryModelas default query class. (breaking change)Move__advanced_search__and__simple_search__class attributes fromModelBasetoQueryModel. (breaking change)IntroduceQueryModel.__search_filters__which can define a canonical set of search filters which can then be referenced in the list version of__advanced_search__and__simple_search__.Modify the logic ofQueryModel.search()to use a subquery joined onto the originating query in order to support pagination when one-to-many and many-to-many joins are present on the originating query. (breaking change)Support passing in a callable that returns a column attribute foralchy.search.<method>(). Allows foralchy.search.contains(lambda: Foo.id)to be used at the class attribute level whenFoo.idwill be defined later.Add search operatorsany_/notany_andhas/nothaswhich can be used for the corresponding relationship operators.v0.10.0 (2014-04-02)Issue warning instead of failing when installed version of SQLAlchemy isn’t compatible withalchy.Query’s loading API (i.e. missingsqlalchemy.orm.strategy_options.Load). This allowsalchyto be used with earlier versions of SQLAlchemy at user’s own risk.Addalchy.searchmodule which provides compatible search functions forModelBase.__advanced_search__andModelBase.__simple_search__.v0.9.1 (2014-03-30)ChangeModelBase.sessionto proxyModelBase.query.session.AddModelBase.object_sessionproxy toorm.object_session(ModelBase).v0.9.0 (2014-03-26)Removeengine_config_prefixargument toManager(). (breaking change)Add explicitsession_optionsargument toManager(). (breaking change)Change theManager.configoptions to follow Flask-SQLAlchemy. (breaking change)AllowManager.configto be either adict,class, ormodule object.Add multiple database engine support using a singleManagerinstance.Add__bind_key__configuration option forModelBasefor binding model to specific database bind (similar to Flask-SQLAlchemy).v0.8.0 (2014-03-18)ForModelBase.update()don’t nestupdate()calls if field attribute is adict.Deprecatedrefresh_on_emptyargument toModelBase.to_dict()and instead implementModelBase.__to_dict__configuration property as place to handle processing of model before casting todict. (breaking change)AddModelBase.__to_dict__configuration property which handles preprocessing for model instance and returns a set of fields as strings to be used as dict keys when callingto_dict().v0.7.0 (2014-03-13)Renamealchy.ManagerBasetoalchy.ManagerMixin. (breaking change)Addpylintsupport.Remove dependency onsix.v0.6.0 (2014-03-10)Prefix event decorators which did not start withbefore_orafter_withon_. Specifically,on_set,on_append,on_remove,on_append_result,on_create_instance,on_instrument_class,on_mapper_configured,on_populate_instance,on_translate_row,on_expire,on_load, andon_refresh. (breaking change)Remove lazy engine/session initialization inManager. Require thatModelandconfigbe passed in at init time. While this removes some functionality, it’s done to simplify theManagercode so that it’s more straightforward. If lazy initialization is needed, then a proxy class should be used. (breaking change)v0.5.0 (2014-03-02)AddModelBase.primary_keyclass property for retrieving primary key(s).AddBase=Noneargument tomake_declarative_base()to support passing in a subclass ofModelBase. Previously had to create a declarativeModelto pass in a subclassedModelBase.Let any exception occurring inModelBase.queryattribute access bubble up (previously,UnmappedClassErrorwas caught).Python 2.6 and 3.3 support.PEP8 compliance.New dependency:six(for Python 3 support)v0.4.2 (2014-02-24)InModelBase.to_dict()only include fields which are mapper descriptors.Supportto_dictmethod hook when iterating over objects inModelBase.to_dict().Addto_dictmethod hook toEnumSymbol(propagates toDeclarativeEnum).v0.4.1 (2014-02-23)Support__iter__method in model so thatdict(model)is equilvalent tomodel.to_dict().Addrefresh_on_empty=Trueargument toModelBase.to_dict()which supports callingModelBase.refresh()if__dict__is empty.v0.4.0 (2014-02-23)AddModelBase.save()method which adds model instance loaded from session to transaction.AddModelBase.get_by()which proxies toModelBase.query.filter_by().first().Add model attributeevents.Add support for multiple event decoration.Add named events for all supported events.Add composite events forbefore_insert_updateandafter_insert_update.v0.3.0 (2014-02-07)RenameModelBase.advanced_search_configtoModelBase.__advanced_search__.RenameModelBase.simple_search_configtoModelBase.__simple_search__AddModelMetametaclass.Implement__tablename__autogeneration from class name.Add mapper event support viaModelBase.__events__and/ormodel.eventdecorator.v0.2.1 (2014-02-03)Fix reference tomodel.make_declarative_baseinManagerclass.v0.2.0 (2014-02-02)Add defaultquery_classto declarative model if none defined.Letmodel.make_declarative_base()accept predefined base and just extend its functionality.v0.1.0 (2014-02-01)First release