[sqlalchemy] Re: Having SA generate constructor when using autoload.

2016-08-24 Thread Piotr Dobrogost
> On Monday, August 22, 2016 at 11:12:11 AM UTC+2, Piotr Dobrogost wrote:
>
> (...)
> Is there a way to hold off this check until after I map this class like 
this
>
> my_table = sa.Table("my_table", meta.metadata, autoload=True, 
autoload_with=engine)
> orm.mapper(MyClass, my_table)
>
> ?

It appears that what I really wanted is a way to use declarative base with 
autoload=True.
I found "SQLAlchemy declarative syntax with autoload (reflection) in 
Pylons" (http://stackoverflow.com/q/4526498/95735) which should solve my 
problem.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] Having SA generate constructor when using autoload.

2016-08-23 Thread Piotr Dobrogost
On Monday, August 22, 2016 at 12:54:27 PM UTC+2, Simon King wrote:
>
>
> You'd probably be best off copying the SQLAlchemy code into your own 
> project - it's not long: 
>
>
> https://bitbucket.org/zzzeek/sqlalchemy/src/5145f671a4b5eb072e996bc450d2946d4be2a343/lib/sqlalchemy/ext/declarative/base.py?at=master=file-view-default#base.py-634
>  
>

Thank you for pointing me to the right place in source.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[sqlalchemy] Having SA generate constructor when using autoload.

2016-08-22 Thread Piotr Dobrogost
I'd like to map a class onto table and automatically get __init__() method 
per 
http://docs.sqlalchemy.org/en/rel_1_0/orm/extensions/declarative/api.html#sqlalchemy.ext.declarative.declarative_base.params.constructor

However when I declare class as

Base = declarative_base(metadata=metadata)
class MyClass(Base):
pass

I get
sqlalchemy.exc.InvalidRequestError: Class  does not have a 
__table__ or __tablename__ specified and does not inherit from an existing 
table-mapped class.

Is there a way to hold off this check until after I map this class like this

my_table = sa.Table("my_table", meta.metadata, autoload=True, 
autoload_with=engine)
orm.mapper(MyClass, my_table)

?

I tried having MyClass inherit from object instead of Base but then I get
TypeError: __init__() got an unexpected keyword argument 'col1'
when calling
x = MyClass(col1=1, col2=2)
, although "my_table" has "COL1" column. So it seems in this case 
__init__() method is not automatically synthesized.

Regards,
Piotr

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] How to generate a file with DDL in the engine's SQL dialect? How to copy engine?

2016-05-11 Thread Piotr Dobrogost
On Wednesday, May 11, 2016 at 12:37:15 PM UTC+2, Simon King wrote:
>
>
> Ah, ok. The problem is that the "sql" parameter in your executor 
> function has not yet been compiled for the dialect in use. Try this 
>

Thanks Simon, this works (SA 1.0.12) although according to the answer in SA 
0.9+ this shouldn't be needed.

Regards,
Piotr

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] How to generate a file with DDL in the engine's SQL dialect? How to copy engine?

2016-05-11 Thread Piotr Dobrogost
> On Wednesday, May 11, 2016 at 11:03:57 AM UTC+2, Simon King wrote:
>> On Wed, May 11, 2016 at 9:39 AM, Piotr Dobrogost 
>>
>> What's the reason for these differences? 
>
> At least for the quoting issue, it sounds like you aren't using the 
> Oracle dialect. What does "print mock_engine.dialect" report? 

 


Regards,
Piotr

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] How to generate a file with DDL in the engine's SQL dialect? How to copy engine?

2016-05-11 Thread Piotr Dobrogost
On Monday, May 9, 2016 at 5:05:11 PM UTC+2, Mike Bayer wrote:
>
>
> the only thing that is sigificant with "mock" is the first part of the 
> URL.   You can just send the whole URL though, so just like this: 
>

> mock_engine = create_engine(real_engine.url, strategy="mock", ...) 
>

I see differences between SQL emitted by mock engine and the one emitted by 
real engine.
Some columns in my db use JsonType which is based on Text type:

class JsonType(TypeDecorator):
impl = Text
(...)

class Tab(Base):
annotations = Column(NestedMutationDict.as_mutable(JsonType))
(...)

For these columns the type used by mock engine is TEXT whereas the type 
used by real engine is CLOB.

>From mock:

CREATE TABLE nodes (
id INTEGER NOT NULL, 
type VARCHAR(30) NOT NULL, 
parent_id INTEGER, 
position INTEGER, 
_acl TEXT, 
name VARCHAR(250), 
title VARCHAR(250), 
annotations TEXT, 
path VARCHAR(2000), 
PRIMARY KEY (id), 
UNIQUE (parent_id, name), 
FOREIGN KEY(parent_id) REFERENCES nodes (id)
)

>From real engine:
CREATE TABLE nodes (
id INTEGER NOT NULL, 
type VARCHAR2(30 CHAR) NOT NULL, 
parent_id INTEGER, 
position INTEGER, 
"_acl" CLOB, 
name NVARCHAR2(250), 
title NVARCHAR2(250), 
annotations CLOB, 
path NVARCHAR2(2000), 
PRIMARY KEY (id), 
UNIQUE (parent_id, name), 
FOREIGN KEY(parent_id) REFERENCES nodes (id)
)

The second difference is that real engine quotes the name of column which 
begins with underscore (_acl) but the mock one does not. Oracle treats 
unquoted version as invalid giving the following error:
ORA-00911: invalid character


What's the reason for these differences?


Regards,
Piotr

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] How to generate a file with DDL in the engine's SQL dialect? How to copy engine?

2016-05-11 Thread Piotr Dobrogost
On Tuesday, May 10, 2016 at 2:55:44 PM UTC+2, Simon King wrote:
>
>
> Could you use Alembic's offline mode? 
>
> http://alembic.readthedocs.io/en/latest/offline.html 
>

Thanks.
Will try.

Regards,
Piotr 

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] How to generate a file with DDL in the engine's SQL dialect? How to copy engine?

2016-05-10 Thread Piotr Dobrogost
On Monday, May 9, 2016 at 5:05:11 PM UTC+2, Mike Bayer wrote:
>
>
> the only thing that is sigificant with "mock" is the first part of the 
> URL.   You can just send the whole URL though, so just like this: 
>
> mock_engine = create_engine(real_engine.url, strategy="mock", ...) 
>

Thanks Mike.
In addition to DDL that comes from .create_all() there's additional DDL 
created by alembic. Is it possible to filter all log messages generated by 
SA by type of SQL (DDL in this case)?

Regards,
Piotr

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[sqlalchemy] How to generate a file with DDL in the engine's SQL dialect? How to copy engine?

2016-05-09 Thread Piotr Dobrogost
At http://stackoverflow.com/q/870925/95735 there's a question titled "How 
to generate a file with DDL in the engine's SQL dialect in SQLAlchemy?" 
with the answer which gives the following code:

engine = create_engine( 'mssql+pyodbc://./MyDb', strategy='mock', executor= 
lambda sql, *multiparams, **params: print (sql)

In my case engine comes "from outside" so in order to make use of the above 
code I would have to clone engine changing only 'strategy' and 'executor'. 
I see  neither Engine.clone() method nor a parameter to create_engine() 
taking already existing engine as a template on which the new engine would 
be based upon. Is there any way to do such a copy and modification?
Is the answer above still the best way to get DDL resulting from calling 
create_all()?


Best regards,
Piotr Dobrogost

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] Bug in BufferedColumnResultProxy class?

2016-04-28 Thread Piotr Dobrogost
On Wednesday, April 27, 2016 at 6:41:24 PM UTC+2, Mike Bayer wrote:
>
>
>
> On 04/27/2016 11:11 AM, Mike Bayer wrote: 
> > 
> > I'm improving our test suite by ensuring that result processors are 
> > fired off for all result proxy subtypes when caching is used as well and 
> > I will ensure the line of code you mention is exercised.  If I can 
> > reproduce your described issue at that level, then the bug will be 
> > located and fixed.   I'll keep you posted. 
> > 
>
> with query caching enabled the issue is reproduced with new test cases, 
> a fix for the issue is in review via the link at 
>
> https://bitbucket.org/zzzeek/sqlalchemy/issues/3699/buffferedcolumnresultproxy-with.
>  
>
>

I would like to thank you Mike very much for your assistance, perseverance, 
invaluable help and the fix.
Your support is exemplar.

Best regards from users of your excellent SQLAlchemy,
Marcin Raczyński i Piotr Dobrogost from Poland

ps.
The original investigation of the issue and suggested fix was done by 
Marcin Raczyński.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] Bug in BufferedColumnResultProxy class?

2016-04-26 Thread Piotr Dobrogost
On Tue, Apr 26, 2016 at 12:18 AM, Mike Bayer <mike...@zzzcomputing.com> wrote:
>
> On 04/25/2016 11:04 AM, Piotr Dobrogost wrote:
>>
>> Is caching using dogpile what you call "Query cache extension"? If so
>> we don't use it.
>
> this extension:
> http://docs.sqlalchemy.org/en/rel_1_0/orm/extensions/baked.html?highlight=baked#module-sqlalchemy.ext.baked

Ok. I see this being used in Kotti (the framework I use). For example
here 
https://github.com/Kotti/Kotti/blob/0d162332e369dedb1b4936935e43de89e9665f8e/kotti/resources.py#L812

> the stack trace shown here illustrates an INSERT statement in the context of
> an ORM flush, which does use the compiled_cache feature; so to that degree,
> this part of the puzzle makes sense.

I'm curious what in the log shows that we deal with "INSERT statement
in the context of an ORM flush"?

> However, in cx_oracle, an INSERT statement does not return rows there's no
> data to be returned; cursor.description should be None and the
> BufferredColumnResultProxy will not be used.An INSERT statement in
> Oracle that uses "RETURNING", as is usually the case for the ORM INSERT
> statement, uses OUT parameters to achieve this and will make use of the
> ReturningResultProxy to work around what's needed here.

Ok.

> Since we're working without a test case of any kind, are you sure that the
> result proxy indicating the problem is not a ReturningResultProxy ?   Are we
> dealing with a column that has a server-generated default value that is of
> type BLOB, CLOB, or similar ?

There is ReturningResultProxy in the call stack for example here
https://gist.github.com/piotr-dobrogost/6d57cacb9e77f59748353b2b6c1334d7#file-call-stack-while-executing-line-519-of-result-py-run-for-the-first-time-ever-during-app-startup-L58

and it's the type of "self" which I showed here

https://gist.github.com/piotr-dobrogost/6d57cacb9e77f59748353b2b6c1334d7#file-call-stack-while-executing-line-519-of-result-py-run-for-the-first-time-ever-during-app-startup-L74

It occurred to me that one can reproduce this rather easily installing
Kotti framework alone (or rather slightly modified version adjusted to
work with Oracle which you can find at
https://github.com/piotr-dobrogost/Kotti/tree/sfx). Kotti has
requirements.txt file where you can replace Kotti==1.3.0-alpha.4 with
git+https://github.com/piotr-dobrogost/Kotti.git@sfx and install
everything with `pip install --no-deps -r requirements.txt`. Running
is simple with `pserve development.ini` command (as Kotti is based on
Pyramid). Before running you have to edit development.ini and change
sqlalchemy.url to point to your Oracle db. When run Kotti creates and
populates db and when you try to access app at http://localhost:5000/
the error happens.


Regards,
Piotr Dobrogost

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] Declaring column NOT NULL only for specific dialect (Oracle)?

2016-04-26 Thread Piotr Dobrogost
On Tue, Apr 26, 2016 at 4:42 PM, Mike Bayer <mike...@zzzcomputing.com> wrote:
>
> So first we'll take a breathbreathe...and we're back.  The best thing
> about air is that it's in most places we live and it's free.

Breathing is very important indeed :) I highly recommend taking
freediving course to anyone – 5 minutes without breathing is really
unique experience.

>  So going back
> to the link I sent,
> http://docs.sqlalchemy.org/en/rel_1_0/core/ddl.html?highlight=createtable#sqlalchemy.schema.CreateColumn
> , scroll down and the second example illustrates how to get the default DDL
> for the column, as rendered by the current compiler, here is a 5 second
> adaptation of that:
>
> from sqlalchemy.schema import CreateColumn
>
> @compiles(CreateColumn, "oracle")
> def _do_thing(element, compiler, **kw):
> text = compiler.visit_create_column(element, **kw)
> text = text.replace("NOT NULL", "NULL")
> return text
>
> I hope this helps.

I own you explanation which I should have written in my last post. In
the end the need to change nullability concerned only one table so I
went with

elif engine.dialect.name == 'oracle':  # pragma: no cover
Node.name.prop.columns[0].nullable = True

in Kotti framework which works.

Questions I asked in my last post are concerned more with implementing
IDENTITY for Oracle. Here the situation is not so simple and simply
replacing text is not possible as "GENERATE AS IDENTITY" phrase must
be placed in right order with regard to other keywords. That's what
made me looking at DDLCompiler.get_column_specification() and what
lead me to asking the questions I asked. I assure you I've read the
link you sent before asking my questions. This example just doesn't
seem to answer those questions.

I'd like you to know that I'm treating our conversation as occasion to
learn more about SA and to know how things should be done. Replacing
NOT NULL with NULL or vice versa is just very specific way of solving
particular problem and does not bring me closer to knowing how to
manipulate DDL for column creation in general.


Regards,
Piotr Dobrogost

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] Declaring column NOT NULL only for specific dialect (Oracle)?

2016-04-26 Thread Piotr Dobrogost
On Fri, Apr 22, 2016 at 5:57 PM, Mike Bayer <mike...@zzzcomputing.com> wrote:
>
> On 04/22/2016 11:51 AM, Piotr Dobrogost wrote:
>>
>>  >Column('some_col', nullable=False, info={"oracle_not_null": False})
>>  >
>>  >then in your @compiles recipe look for column.info
>> <http://column.info/>['oracle_not_null']
>>  >while at the same time looking at compiler.dialect.name
>> <http://compiler.dialect.name/> == 'oracle'.
>>
>> I get it. However as we want this for every autoincrement column I guess
>> we can check for already provided "autoincrement" flag and avoid passing
>> column.info altogether. Nice.
>>
>> It seems like this could be used to render IDENTITY keyword for
>> autoincrement columns for Oracle 12c which I asked about recently in my
>> post titled "Support for Oracle 12c auto increment (IDENTITY) columns?"
>> (https://groups.google.com/forum/#!topic/sqlalchemy/Jg_kV6VF0_E).
>
>
> yes, you can write whatever rendering you want in there.


Do I see right, that using @compiles(schema.CreateColumn, 'oracle') is
not good as it's being invoked too late to have access to colspec?

It seems I have to override DDLCompiler.get_column_specification() and
then I have to copy & paste code from this method because there's no
way to reuse code which generates DEFAULT and NULL statements, yes?
Overriding DDLCompiler.get_column_specification() means I subsequently
have to "register" my DDLCompiler's subclass somehow. How do I do it?
I did not find any information on this in docs. Looking at PGDialect
in source, there's ddl_compiler attribute but I don't see any API to
change it. You don't want me to monkey patch OracleDialect, do you?.

Regards,
Piotr Dobrogost

ps.
I have an impression there's hardly any traffic on #sqlalchemy during
Europe's working hours :(

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] Bug in BufferedColumnResultProxy class?

2016-04-25 Thread Piotr Dobrogost
On Mon, Apr 25, 2016 at 3:23 PM, Mike Bayer <mike...@zzzcomputing.com> wrote:
>
> OK I can try to work with that but that's a very specific feature, you'd
> need to be using the Query cache extension,

I have problem finding information on "Query cache extension".
Googling for  I get
http://docs.sqlalchemy.org/en/latest/orm/examples.html#module-examples.dogpile_caching
as the first result from SA's docs and
http://stackoverflow.com/questions/204918/does-sqlalchemy-support-caching
as the first result from Stackoverflow.

Is caching using dogpile what you call "Query cache extension"? If so
we don't use it.

>  or using the "compiled_cache"
> option,

There's no "compiled_cache" string in Kotti framework so I guess we
don't use it.

> option, *or* the error is being generated within the context of a Session
> being flushed within an INSERT or UPDATE RETURNING statement, which itself I
> don't think uses the traditional result set model in Oracle anyway.

It's hard to say. Right before printing call stack from line 519 of
result.py there's SELECT logged:
2016-04-25 16:36:02,954 INFO
[sqlalchemy.engine.base.Engine][waitress] SELECT nodes.id AS nodes_id,
nodes.type AS nodes_type, nodes.parent_id AS nodes_parent_id,
nodes.position AS nodes_position, nodes."_acl" AS nodes__acl,
nodes.name AS nodes_name, nodes.title AS nodes_title,
nodes.annotations AS nodes_annotations, nodes.path AS nodes_path
FROM nodes LEFT OUTER JOIN contents ON nodes.id = contents.id LEFT
OUTER JOIN documents ON contents.id = documents.id LEFT OUTER JOIN
files ON contents.id = files.id LEFT OUTER JOIN images ON contents.id
= images.id
WHERE nodes.parent_id IS NULL

and right before the traceback is printed there's rollback being logged:
2016-04-25 16:36:02,975 INFO  [sqlalchemy.engine.base.Engine][waitress] ROLLBACK

however I don't know if it answers your last question.

> any of these true for your case ?  Looks like you haven't provided a stack
> trace for your issue, I'm sure you have that, so send that along.

Please find all information at
https://gist.github.com/piotr-dobrogost/6d57cacb9e77f59748353b2b6c1334d7
Probably you are most interested in the raw log (file named "Full log
from the start of the application (with empty db)"). Please note that
I modified line 519 in result.py by inserting the following code:
import traceback; traceback.print_stack();
to get call stack at this moment of execution.
Also the nature of the bug is such that there's no information in the
log about original problem (not executing some processors which were
registered and executed earlier). I'm guessing there are scopes during
which one should not modify the list of registered processors. If it
happens that this list (as a consequence of this bug) is being cleared
while one of such scopes that it would be awesome if SA could somehow
notice that the list of processors was changed in some scope where it
should be left intact and log warning or raise hard error. This way
the reason for error would be much easier to find in this case and
probably also in future.


Regards,
Piotr Dobrogost

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] Bug in BufferedColumnResultProxy class?

2016-04-25 Thread Piotr Dobrogost
On Friday, April 22, 2016 at 5:22:38 PM UTC+2, Mike Bayer wrote:
>
>
> On 04/22/2016 10:40 AM, Piotr Dobrogost wrote: 
> > It seems BufferedColumnResultProxy class (used only in Oracle dialect) 
> > has a bug. 
>
 

> I cannot confirm it, would need a test case.  Here's one that is 
> extremely simple but exercises the features you describe.   I have no 
> doubt that what you're seeing is a bug however so I'd need to know what 
> to add to this test to illustrate the issue: 
>

Thanks for quick response and creation of sample code. We have trouble 
adding something that would trigger bug as we don't fully understand source 
code of SA and in addition we use other framework (Kotti) which adds its 
layer of complexity. Having said that we think that what's needed to 
reproduce bug is to modify your test case so that line 519 in result.py 
would get hit 
(https://github.com/zzzeek/sqlalchemy/blob/rel_1_0_12/lib/sqlalchemy/engine/result.py#L519).

There is no need for you or your developers to attempt to debug deep 
> issues like these; I can identify them within minutes given a 
> demonstration of the behavior and I am glad to do this work once an 
> incorrect behavior is demonstrated. 
>

Thank you very much for offering your help. 

The work that you need to do when you encounter stack traces like this 
> is to isolate the behavior into a simple test case, such as the one I 
> have above.Using the "divide and conquer" approach, where you begin 
> with your whole application, then slowly remove pieces of it that 
> continue to exhibit the bad behavior until you have something entirely 
> minimal.  The guidelines that I often refer to at 
> http://stackoverflow.com/help/mcve have an excellent description of this. 
>

Sure thing. The problem in practice is that in order to create "simple test 
case" it's often needed to get good understanding of used libraries at the 
source code level. The good example is your sample test case which we don't 
know how to modify in spite of the fact that we suspect which specific line 
needs to be hit.


Regards,
Piotr Dobrogost

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[sqlalchemy] Making column not nullable for specific dialect (Oracle)

2016-04-23 Thread Piotr Dobrogost
Hi!

Unfortunately it's impossible to insert empty string in not null column in 
Oracle (http://stackoverflow.com/q/203493/95735).
That's why I would like to declare specific column as nullable only for 
Oracle dialect.
How to do this?


Regards,
Piotr Dobrogost

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[sqlalchemy] Bug in BufferedColumnResultProxy class?

2016-04-22 Thread Piotr Dobrogost
It seems BufferedColumnResultProxy class (used only in Oracle dialect) has 
a bug.

_init_metadata() method defined at 
https://github.com/zzzeek/sqlalchemy/blob/rel_1_0_12/lib/sqlalchemy/engine/result.py#L1238
is being called even for already cached data (that's probably bug) and 
because this method clears a list of processors (metadata._processors = 
[None for _ in range(len(metadata.keys))]) the list of original processors 
(metadata._orig_processors) gets cleared the second time _init_metadata() 
method is called. The end result is that column's value is not being 
processed to proper Python type from the db original type and one gets 
errors like:

File 
"/home/piotr/.virtualenvs/kotti/lib/python2.7/site-packages/sqlalchemy/ext/mutable.py",
 
line 403, in coerce
raise ValueError(msg % (key, type(value)))
ValueError: Attribute '_acl' does not accept objects of type 

Whole traceback is available at http://pastebin.com/Ssui33XC

Guarding method's body after line L1240 with "if not hasattr(metadata, 
'_orig_processors'):" solves the problem but it's neither pretty nor it's 
the right solution. The right solution is probably to not call 
_init_metadata() method on cached data at all.

I'd appreciate if someone with good understanding of SA internals could 
take a look and confirm (better yet fix) this bug. I have to admit it took 
a top notch developer a couple of hours of debugging to go through much of 
SA code and establish the root cause of this problem.

I'm going to raise issue on tracker as soon as someone confirms this bug.

Best regards,
Piotr Dobrogost

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[sqlalchemy] Declaring column NOT NULL only for specific dialect (Oracle)?

2016-04-22 Thread Piotr Dobrogost

As Oracle does not support inserting empty string into NOT NULL column I 
would like to declare specific column as nullable only for Oracle.
How can I do this?

Regards,
Piotr Dobrogost

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] Accessing name of the table in class' attributes.

2016-04-21 Thread Piotr Dobrogost
nships.py",
 
line 1683, in _process_dependent_arguments
util.to_column_set(self.remote_side))
  File 
"/home/piotr/.virtualenvs/kotti/lib/python2.7/site-packages/sqlalchemy/orm/relationships.py",
 
line 1682, in 
    for x in
  File 
"/home/piotr/.virtualenvs/kotti/lib/python2.7/site-packages/sqlalchemy/sql/elements.py",
 
line 3820, in _only_column_elements
"'%s'; got: '%s', type %s" % (name, element, type(element)))
sqlalchemy.exc.ArgumentError: Column-based expression object expected for 
argument 'remote_side'; got: '', type 


Regards,
Piotr  Dobrogost

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[sqlalchemy] Accessing name of the table in class' attributes.

2016-04-20 Thread Piotr Dobrogost
Having this code

class Base(object):
@declared_attr
def __tablename__(cls):
return '{0}s'.format(camel_case_to_name(cls.__name__))


class Model(Base):
id = Column(Integer, Sequence(???, optional=True), primary_key=True)


is there a way to use name of Model's table inside declaration of "id" 
column?


Regards,
Piotr Dobrogost

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[sqlalchemy] Posting SQLAlchemy-Continnum related posts to this group?

2016-04-18 Thread Piotr Dobrogost
Hi!

Is it allowed to post questions regarding SQLAlchemy-Continuum's extension 
to SQLAlchemy to this group?
I raised related issue at 
https://github.com/kvesteri/sqlalchemy-continuum/issues/138


Regards,
Piotr Dobrogost

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[sqlalchemy] Re: Feedback on "Basic Relationship Patterns" docs

2016-04-13 Thread Piotr Dobrogost
On Monday, April 11, 2016 at 3:58:59 PM UTC+2, Ryan Govostes wrote:

The documentation would be improved by switching to more intuitive 
examples. How about

One To Many, Many To One: Countries and Cities
One To One: Capitals and Countries
Many To Many: Organizations and Members

I like this. Make Many To Many: Countries and Languages and this makes very 
nice example.

Regards,
Piotr Dobrogost

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] Support for Oracle 12c auto increment (IDENTITY) columns?

2016-04-13 Thread Piotr Dobrogost
Mike,

Thanks for your reply!

On Wednesday, April 13, 2016 at 1:15:32 PM UTC+2, Mike Bayer wrote:
>
> We've not started supporting new oracle 12c features as of yet, in this 
> case it might be possible to get it working with some dialect flags since 
> we already use "returning" to get at the newly generated primary key, 
> although testing would be needed and other assumptions in the dialect might 
> get in the way.


Which flags do you have in mind? Looking at 
http://docs.sqlalchemy.org/en/latest/dialects/oracle.html I don't see 
anything which might be useful to make it work.

I was surprised Oracle needs different syntax with explicit sequence in SA. 
Having one syntax for auto increment column (primary key) across all 
backends seems like very important feature to have.  What is the reason 
there's no Oracle dialect option to generate and use suitable sequence for 
such column? Is there some recipe solving this problem?


Regards,
Piotr Dobrogost

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[sqlalchemy] Support for Oracle 12c auto increment (IDENTITY) columns?

2016-04-13 Thread Piotr Dobrogost
Hi all!

At 
http://docs.sqlalchemy.org/en/latest/dialects/oracle.html#auto-increment-behavior
 
we read that:
"With the Oracle dialect, a sequence must always be explicitly specified to 
enable autoincrement."

However, starting with version 12c Oracle supports autoincrement columns 
(see update in this answer http://stackoverflow.com/a/11296469/95735).

Does SQLAlchemy make use of this new feature of Oracle 12c so that it's not 
necessary to explicitly specify sequence in declaration of table columns 
(so that single declaration of such column works for Oracle and other 
databases)? If so, do I have to enable this somehow?

Regards,
Piotr Dobrogost




-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] OperationalError with SQLite with simple update query

2016-03-19 Thread Piotr Dobrogost
On Wednesday, March 16, 2016 at 4:41:38 PM UTC+1, Simon King wrote:
>
>
> Hmm, ok. In that case, does it work if you use "TextValue.id.in_(ids)" 
> rather than Node? I can't tell from your 
>

Yes, this works – see my last post in this thread.
 

> description if the "id" and "value" columns are both present on the 
> TextValue table, or if you actually need to join to the Node class.
>

Both TextValue and Node have "id" column and "value" column is only in 
TextValue table. To get TextValue object all tables for superclasses of 
TextValue have to be joined which is how joined table inheritance works.

Abbreviated models below:

class TextValue(Content):
id = Column(Integer, ForeignKey('contents.id'), primary_key=True)
value = Column(Unicode)


class Content(Node):
@classproperty
def __mapper_args__(cls):
return dict(polymorphic_identity=camel_case_to_name(cls.__name__))

id = Column(Integer, ForeignKey('nodes.id'), primary_key=True)
(...)


class Node(Base, ContainerMixin, PersistentACLMixin):
__table_args__ = (UniqueConstraint('parent_id', 'name'))

__mapper_args__ = dict(
polymorphic_on='type',
polymorphic_identity='node',
with_polymorphic='*',
)

id = Column(Integer(), primary_key=True)
type = Column(String(30), nullable=False)
parent_id = Column(ForeignKey('nodes.id'), index=True)
()

It does seem like a bug that SA is generating this SQL.
>

I would thought so but I don't know SA to be sure.


Regards,
Piotr 

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] OperationalError with SQLite with simple update query

2016-03-19 Thread Piotr Dobrogost
On Wednesday, March 16, 2016 at 3:51:16 PM UTC+1, Simon King wrote:
>
> On Wed, Mar 16, 2016 at 1:43 PM, Piotr Dobrogost <
> p...@2016.groups.google.dobrogost.net > wrote:
>
>> Hi!
>>
>> When executing below code
>>
>> DBSession.query(TextValue).\
>> filter(Node.id.in_(ids)).\
>> update({TextValue.value: appstruct['text_value']},
>>  synchronize_session=False)
>>
>> I get this error:
>> OperationalError: (sqlite3.OperationalError) near "FROM": syntax error 
>> [SQL: u'UPDATE text_values SET value=? FROM nodes WHERE nodes.id IN (?, 
>> ?, ?, ?)'] [parameters: (u'zzz', u'1685', u'175', u'1688', u'180')]
>>
>>
>>  

> I'm not sure if sqlite supports multi-table updates. Do you know what sort 
> of SQL you are expecting to generate here?
>

I would expect "normal" UPDATE with WHERE clause. I'm not sure where does 
FROM come from here as the new value is given explicitly and not to be read 
from existing rows.
 

> (Note that your query appears at least to be missing a join condition 
> between the TextValue and Node classes)
>

TextValue is a subclass of Content which is a subclass of Node.
Content declares this:
@classproperty
def __mapper_args__(cls):
return dict(polymorphic_identity=camel_case_to_name(cls.__name__))

so TextValue and Node should be implicitly joined according to rules for 
joined table polymorphism in SA.
 

Regards,
Piotr

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[sqlalchemy] OperationalError with SQLite with simple update query

2016-03-19 Thread Piotr Dobrogost
Hi!

When executing below code

DBSession.query(TextValue).\
filter(Node.id.in_(ids)).\
update({TextValue.value: appstruct['text_value']},
 synchronize_session=False)

I get this error:
OperationalError: (sqlite3.OperationalError) near "FROM": syntax error 
[SQL: u'UPDATE text_values SET value=? FROM nodes WHERE nodes.id IN (?, ?, 
?, ?)'] [parameters: (u'zzz', u'1685', u'175', u'1688', u'180')]

Does SA construct query which is not valid in SQLite?
How can I solve this problem?

Regards,
Piotr Dobrogost

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] Re: Can I make bulk update through association proxy?

2016-03-18 Thread Piotr Dobrogost
On Saturday, February 27, 2016 at 10:26:53 PM UTC+1, Mike Bayer wrote:
>
>
> If I can just wrap this up, do i understand correctly that this would 
> the functionality of "joined eager loading", except applied to something 
> like an UPDATE..FROM ? 
>

I think so although I can't say I'm 100% sure as I'm not fluent in neither 
SA nor in SQL.

Jonathan Vanasco wrote earlier: 
>For this general task, I `flush` the session, use the `update` command on 
the target class -- filtering the >WHERE based on the parent object and 
 join conditions --  then I `expire_all` (because that update may have 
>affected in-memory object relations).  There is a small hit on reloading 
all the data, but I've found the `update` >to run considerably faster and 
make it worth-it.

This explains how to do this starting from the "opposite end". I mean the 
situation is that there's some parent_class <-relationship-> target_class 
and I want to update objects of target_class having initially objects of 
parent_class without explicitly selecting objects of target_class first as 
in Jonathan's solution.

Regards,
Piotr

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] Re: Can I make bulk update through association proxy?

2016-02-27 Thread Piotr Dobrogost
On Friday, February 26, 2016 at 7:45:46 PM UTC+1, Jonathan Vanasco wrote:

I'm not either, and I'm scared of the SQL that would be generated and the 
> wire traffic/memory if there were.  That would be subselects within 
> subqueryloads within... this also seems a bit more about "updates to 
> associations" vs "association_proxy".  
>

True. I admit this would be rather complicated but as I'm new to SA and 
everybody has SA in high regard I hoped it could be capable of doing such a 
thing.

Thanks for taking time to reply and for all information you provided which 
is very helpful.

Regards,
Piotr

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] Re: Can I make bulk update through association proxy?

2016-02-26 Thread Piotr Dobrogost
On Thursday, February 25, 2016 at 2:33:13 PM UTC+1, Simon King wrote:

Maybe I'm not understanding your question properly. The return value from 
> query.all() is a plain python list. You're asking for it to return a 
> different kind of object, that wraps the underlying list and allows you to 
> specify arbitrary operations that should be applied to each object in that 
> list? I guess I could imagine a complicated class that might support 
> something like that, but I don't think it exists at the moment, and it 
> would seem like a lot of work just to avoid a simple loop...
>

Well, after calling .all() you indeed get plain python list and you can't 
do anything but iterate over it; it's "too late". In this case it appears 
one should not call .all() and instead call something on the query itself 
i.e. session.query(Text).???.update(...). I would like to know if and what 
to insert so that SA would generate UPDATE for objects _related_ (those 
accessible via association proxy) to these selected objects.

Regards,
Piotr

>

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] Re: Can I make bulk update through association proxy?

2016-02-25 Thread Piotr Dobrogost
On Thursday, February 25, 2016 at 11:10:36 AM UTC+1, Simon King wrote
>
>
> I can't think of a way you could do this with objects you've already 
> loaded into memory. Perhaps you could use Query.update to issue the 
> appropriate SQL directly to the database?
>
>
> http://docs.sqlalchemy.org/en/rel_1_0/orm/query.html#sqlalchemy.orm.query.Query.update
>

Thanks for your reply.
My reasoning is that if it's possible for one object (and it is) it should 
be possible for multiple objects as well.
It seems to use Query.update I would need to filter/select related objects 
(those accessible through association proxy) directly and this is 
inconvenient as I would like to treat them as part of the primary objects 
and be able to filter/select them for update "through" primary objects by 
means of association proxy.

Regards,
Piotr

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[sqlalchemy] Re: Can I make bulk update through association proxy?

2016-02-25 Thread Piotr Dobrogost
On Wednesday, February 24, 2016 at 2:41:43 PM UTC+1, Piotr Dobrogost wrote:
>
> Hi!
>
> Let's say I have a model Text with attribute "values" which is association 
> proxy.
> I can update single object like this:
> text = session.query(Text).one()
> text.values.update(...)
>
> How can I update multiple objects with the same value without manually 
> looping over result of a query?
> texts = session.query(Text).all()
> texts???values???.update(...)
>

Any hints? 

Regards,
Piotr
 

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] Dependency rule tried to blank-out primary key column when trying to update using association proxy

2016-02-24 Thread Piotr Dobrogost
On Wednesday, February 24, 2016 at 4:07:07 PM UTC+1, Mike Bayer wrote:
>
>
> There might be an old issue in bitbucket that the way associationproxy 
> insists on calling clear() without any hook to override, the AP has a 
> lot of old override hooks that are complicated and difficult to use, and 
> then don't even cover this case.  So the AP is just not great in this 
> area and I'd prefer subclassing is not the idiomatic solution to this. 
>

I found this one – "try to add a real "replace collection" to association 
proxy" (https://bitbucket.org/zzzeek/sqlalchemy/issues/2642/)

Regards,
Piotr

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] Dependency rule tried to blank-out primary key column when trying to update using association proxy

2016-02-24 Thread Piotr Dobrogost
On Wednesday, February 24, 2016 at 4:21:58 AM UTC+1, Mike Bayer wrote:


in that way you can control exactly what __set__() does and it will 
> never remove a TextValue object where the same identity is coming in on 
> assignment. 
>

One more question; is this described somewhere in the docs? I don't see it 
at http://docs.sqlalchemy.org/en/latest/orm/extensions/associationproxy.html


Regards,
Piotr

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[sqlalchemy] Can I make bulk update through association proxy?

2016-02-24 Thread Piotr Dobrogost
Hi!

Let's say I have a model Text with attribute "values" which is association 
proxy.
I can update single object like this:
text = session.query(Text).one()
text.values.update(...)

How can I update multiple objects with the same value without manually 
looping over result of a query?
texts = session.query(Text).all()
texts???values???.update(...)


Regards,
Piotr Dobrogost

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] Dependency rule tried to blank-out primary key column when trying to update using association proxy

2016-02-24 Thread Piotr Dobrogost
On Wednesday, February 24, 2016 at 4:21:58 AM UTC+1, Mike Bayer wrote:

in that way you can control exactly what __set__() does and it will 
> never remove a TextValue object where the same identity is coming in on 
> assignment. 
>

Mike, thank you very much for your help.
 
Regards,
Piotr

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[sqlalchemy] Dependency rule tried to blank-out primary key column when trying to update using association proxy

2016-02-23 Thread Piotr Dobrogost
Hi!

I'm getting AssertionError: Dependency rule tried to blank-out primary key 
column 'text_value.text_id' on instance '' 
error while trying to update row using association proxy ('values') like 
this:

session.add(Text(values={'pl': u'org', 'en': u'org'}))
text = session.query(Text).one()
text.values = {'pl': u'modified', 'en': u'modified'}
session.commit()


Working example is at 
https://gist.github.com/piotr-dobrogost/74073cf11006fb68e555
What am I doing wrong?


Best regards,
Piotr Dobrogost

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[sqlalchemy] Question about FAQ entry titled "I’m getting a warning or error about “Implicitly combining column X under attribute Y”"

2015-09-08 Thread Piotr Dobrogost
Hi!

In the FAQ there's entry titled "I’m getting a warning or error about 
“Implicitly combining column X under attribute Y”" with the following 
example:

class A(Base):
__tablename__ = 'a'
id = Column(Integer, primary_key=True)

class B(A):
__tablename__ = 'b'
# probably not what you want, but this is a demonstration
id = column_property(Column(Integer, primary_key=True), A.id)
a_id = Column(Integer, ForeignKey('a.id'))


However trying to add yet another class just to see what happens...

class C(B):
__tablename__ = 'c'

id = column_property(Column(Integer, primary_key=True), B.id)
b_id = Column(Integer, ForeignKey('b.id'))


...results in the same kind of error again:
"sqlalchemy.exc.InvalidRequestError: Implicitly combining column b.id with 
column a.id under attribute 'id'.  Please configure one or more attributes 
for these same-named columns explicitly."

How to avoid this?

ps.
This is a follow-up to my recent post 
https://groups.google.com/forum/#!topic/sqlalchemy/n_JEgKYshnE

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] Question about FAQ entry titled "I’m getting a warning or error about “Implicitly combining column X under attribute Y”"

2015-09-08 Thread Piotr Dobrogost
On Tuesday, September 8, 2015 at 1:37:05 PM UTC+2, Richard Kuesters wrote:

| is your "A" class abstract and/or are you using them with polymorphism?

Thank you for taking time to look at this.
If by abstract you mean abstract as defined at 
http://docs.sqlalchemy.org/en/latest/orm/extensions/declarative/api.html?highlight=__abstract__#abstract
 
then no, it's not abstract. As to polymorphism the answer is not so simple. 
Basically using this example I tried to depict situation which I believe 
takes place in SQLAlchemy-Continuum extension. This extension for every 
model creates another one recording all changes to the original one. 
Original models are polymorphic (and use joined table inheritance) and 
create simple hierarchy Node -> Content -> Document which can be seen at 
https://github.com/Kotti/Kotti/blob/9a8684c10fbb3c6fbf6b1265c86b732e1c416c4a/kotti/resources.py
 
I'm not sure if models created by versioning extension (NodeVersion, 
ContentVersion and DocumentVersion) are meant to be polymorphic (supposedly 
as a consequence of original models being polymorphic) or not. Each of 
these models has "transaction_id" attribute mapped to "transaction_id" 
column in mapped table. The error is "sqlalchemy.exc.InvalidRequestError: 
Implicitly combining column contents_version.transaction_id with column 
nodes_version.transaction_id under attribute 'transaction_id'. Please 
configure one or more attributes for these same-named columns explicitly." 
By extending example from FAQ I wanted to understand under what 
circumstances could same-named columns be made to work.

Regards,
Piotr

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] Question about FAQ entry titled "I’m getting a warning or error about “Implicitly combining column X under attribute Y”"

2015-09-08 Thread Piotr Dobrogost
On Tuesday, September 8, 2015 at 4:36:38 PM UTC+2, Richard Kuesters wrote:
>
> well, i'm sorry if i'm pouring could water on you but continuum never 
> worked as expected (at least for me) and i always used 
>

Cold shower it is indeed :(
Nevertheless thank you for your time and interest.

I keep hoping someone has tried continuum with joined table inheritance and 
could point out what's wrong here...

Regards,
Piotr

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[sqlalchemy] Re: [SQLAlchemy-Continuum] sqlalchemy.exc.InvalidRequestError: Implicitly combining column(...) in joined table inheritance scenario

2015-09-07 Thread Piotr Dobrogost
On Sunday, September 6, 2015 at 11:02:36 PM UTC+2, Piotr Dobrogost wrote:
>
> Hi!
>
> I've recently raised a bug on SQLAlchemy-Continuum's tracker at 
> https://github.com/kvesteri/sqlalchemy-continuum/issues/105 
>

As I've got no replies on SQLAlchemy-Continuum's tracker I asked on 
Stackoverflow too – http://stackoverflow.com/q/32438963/95735 

Regards,
Piotr

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[sqlalchemy] [SQLAlchemy-Continuum] sqlalchemy.exc.InvalidRequestError: Implicitly combining column(...) in joined table inheritance scenario

2015-09-06 Thread Piotr Dobrogost
Hi!

I've recently raised a bug on SQLAlchemy-Continuum's tracker 
at https://github.com/kvesteri/sqlalchemy-continuum/issues/105 regarding 
"Implicitly combining column(...)" error when trying to version tables used 
in joined table inheritance scenario.
As there's been very little activity on this project lately I thought I 
would post here hoping someone knows this extension and could shed some 
light on what might be the reason for the error. In the issue there's small 
test case and traceback.
Thank you in advance.

Regards,
Piotr Dobrogost

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] SQLAlchemy-Continnum over 300 failed tests

2015-09-03 Thread Piotr Dobrogost
On Thursday, September 3, 2015 at 3:58:42 PM UTC+2, Michael Bayer wrote:
>
>
> well, I don't even know what SQLAlchemy-Continuum is.Is their 
> bugtracker open on github?
>

You must have forgotten then :) – 
https://groups.google.com/d/msg/sqlalchemy/BGWLUjaFtpY/ubLshcvHlKUJ
They have bug tracker on github 
(https://github.com/kvesteri/sqlalchemy-continuum/issues) but I have 
impression most projects do not welcome _questions_ on their trackers.

Regards,
Piotr

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[sqlalchemy] SQLAlchemy-Continnum over 300 failed tests

2015-09-03 Thread Piotr Dobrogost
Hi!

As SQLAlchemy-Continuum extension does not appear to have its mailing list 
I thought I would ask here. If questions regarding sa-continuum are not 
welcomed here please accept my apologies (and tell me so).

I wanted to try out sa-continuum and I started by running tests with 
`py.test tests`. As a result 319 tests failed, 291 passed, 12 was skipped 
and 5 ended with an error. This is with SQLAlchemy-Continuum 1.2.0, 
SQLAlchemy 1.0.8 and SQLAlchemy-Utils 0.30.17.

Are those failed tests result of me not running tests properly?
Output from py.test with the first 10 failures is 
at https://gist.github.com/piotr-dobrogost/4140267dc9dd654f5560


Regards,
Piotr Dobrogost 

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.