Re: [sqlalchemy] How to automatically handle deletion flags

2014-02-28 Thread RonnyPfannschmidt
need. On Feb 27, 2014, at 10:35 AM, RonnyPfannschmidt ronny.pfa...@gmail.comjavascript: wrote: the problem is that it shouldn't just be taken into account for relationships but all queries that operate on such a table with the flag On Thursday, February 27, 2014 3:22:29 PM UTC+1, Michael

[sqlalchemy] How to automatically handle deletion flags

2014-02-27 Thread RonnyPfannschmidt
Hi, im working on a project where in many tables data can not be deleted, but only marked as deactivated, Propperly handling selection of active data for normal users and all data for admins is turning more and more tendious (in particular wrt relationship configuration) Im wondering if there

Re: [sqlalchemy] How to automatically handle deletion flags

2014-02-27 Thread RonnyPfannschmidt
im already aware of that, but it doesnt expand to relationships and other things basically i need it taken into account in a lot more places On Thursday, February 27, 2014 10:59:21 AM UTC+1, Simon King wrote: On Thu, Feb 27, 2014 at 8:44 AM, RonnyPfannschmidt ronny.pfa...@gmail.com

Re: [sqlalchemy] How to automatically handle deletion flags

2014-02-27 Thread RonnyPfannschmidt
. Hope that helps, Simon On Thu, Feb 27, 2014 at 1:06 PM, RonnyPfannschmidt ronny.pfa...@gmail.com javascript: wrote: im already aware of that, but it doesnt expand to relationships and other things basically i need it taken into account in a lot more places

Re: [sqlalchemy] How to declare a custom type that will imply a check on a column?

2013-12-20 Thread RonnyPfannschmidt
= MetaData() t = Table( 'fun', m, Column('name', PString(100)), ) e = create_engine('sqlite://', echo=1) m.create_all(e) m.drop_all(e) assert 0 On Wednesday, December 18, 2013 5:26:53 PM UTC+1, Michael Bayer wrote: On Dec 18, 2013, at 5:41 AM, RonnyPfannschmidt

Re: [sqlalchemy] How to declare a custom type that will imply a check on a column?

2013-12-20 Thread RonnyPfannschmidt
i discovered a workaround by doing @event.listens_for(PString, after_parent_attach) def create_constraint(target, parent): @event.listens_for(parent, after_parent_attach) def add_to_table(col, table): constraint = CheckConstraint(column(col.name) != text(''), _autoattach=False)

[sqlalchemy] How to declare a custom type that will imply a check on a column?

2013-12-18 Thread RonnyPfannschmidt
Hi, for supporting a certain schema requirement, i have to create a quite a number of columns that are checked not to be a empty string, So i'd like to declare a custom type, which will automatically imply the check on those columns. I already Investigated, how Boolean does this for databases

Re: [sqlalchemy] How to declare a custom type that will imply a check on a column?

2013-12-18 Thread RonnyPfannschmidt
you’d use a TypeDecorator for this. See the example http://docs.sqlalchemy.org/en/rel_0_9/core/types.html#coercing-encoded-strings-to-unicodefor something similar (coerces to utf-8, just replace that with checking for non-empty). Unfortunately that doesn't quite fit, i need a DDL