danielholmstrom / dictalchemy Goto Github PK
View Code? Open in Web Editor NEWAdds asdict() and fromdict() to SQLAlchemy declarative models
License: MIT License
Adds asdict() and fromdict() to SQLAlchemy declarative models
License: MIT License
Title says it all.
When using the .asdict() function in python v3.X the following error is encountered. 'dict' object has no attribute 'iteritems'
Fix is to update Line for (rel_key, orig_args) in follow.iteritems():
with for (rel_key, orig_args) in follow.item():
untils.py on line 120.
This fix is only applicable for python v3, another package should probably be created to maintain v2 support if required.
The test for primary keys update is now done as first test. So even if the primary key fields are in the exclude list, an exception is raised. To circumvent, one needs to set allow_pk to True as well as put the primary key fields in the exclude list. Especially in the case of multi-column primary keys, this is error-prone. If one forgets (or makes a typo in) one primary key field in the exclude list, the allow_pk=True setting will allow an update. IMHO it would be more sensible to first check the exclude list and only if a field survives that, do the primary key check. In that case, allow_pk can be left False so mistakes in the exclude list are still caught.
This now fails while IMHO it should succeed:
h = Named('a name')
h.fromdict({'id': 12345}, exclude=['id'])
This currently succeeds:
h = Named('a name')
h.fromdict({'id': 12345}, allow_pk=True, exclude=['id'])
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.