Re: [sqlalchemy] 1.1.0b1: construct has no default compilation handler.

2016-06-28 Thread Mike Bayer



On 06/28/2016 12:07 PM, Martijn van Oosterhout wrote:



On 28 June 2016 at 15:47, Mike Bayer > wrote:



On 06/28/2016 09:09 AM, Martijn van Oosterhout wrote:


That sqlite reference looks a bit weird, did I miss some
initialisation
somewhere?


It looks like the @compiles system is in place, which SQLAlchemy
does not use internally.  that wasn't in your code example but
that's likely where the exception is raised from.


Bingo! This is some cruft from prehistory of this project, not sure how
exactly it gets loaded, but adding this to the script triggers it reliably:

from sqlalchemy.ext.compiler import compiles

@compiles(ARRAY, "sqlite")
def compile_binary_sqlite(type_, compiler, **kw):
return "STRING"

Now, in my eyes this should have no effect if you're not using sqlite,
but there is obviously something going on. I've verified that this does
not fail on 1.0.0. At least now I can continue testing 1.1.0.


well that's a regression on our end, then.




Have a nice day,
--
Martijn van Oosterhout >
http://svana.org/kleptog/

--
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.


--
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] 1.1.0b1: construct has no default compilation handler.

2016-06-28 Thread Martijn van Oosterhout
On 28 June 2016 at 15:47, Mike Bayer  wrote:

>
>
> On 06/28/2016 09:09 AM, Martijn van Oosterhout wrote:
>
>>
>> That sqlite reference looks a bit weird, did I miss some initialisation
>> somewhere?
>>
>
> It looks like the @compiles system is in place, which SQLAlchemy does not
> use internally.  that wasn't in your code example but that's likely where
> the exception is raised from.
>
>
Bingo! This is some cruft from prehistory of this project, not sure how
exactly it gets loaded, but adding this to the script triggers it reliably:

from sqlalchemy.ext.compiler import compiles

@compiles(ARRAY, "sqlite")
def compile_binary_sqlite(type_, compiler, **kw):
return "STRING"

Now, in my eyes this should have no effect if you're not using sqlite, but
there is obviously something going on. I've verified that this does not
fail on 1.0.0. At least now I can continue testing 1.1.0.

Have a nice day,
-- 
Martijn van Oosterhout  http://svana.org/kleptog/

-- 
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] 1.1.0b1: construct has no default compilation handler.

2016-06-28 Thread Martijn van Oosterhout
On 27 June 2016 at 16:22, Mike Bayer  wrote:

> Not really sure, that URL itself won't allow a psycopg2 connection to even
> occur.


Yeah, I noticed that. psql has sensible defaults here that psycopg2
apparently doesn't have. In this case I'd just stripped the credentials out
of the script, sorry.



> The error means that the construct is trying to be generated as a string,
> like in a print statement.   But 1.1 has a new feature that allows default
> stringification of pg.ARRAY and other constructs to actually work.
>
> Need a stack trace at the very least.
>
>
Good point. Attached. Just to get some more information I put stopped a
debugger at the raise statement and got the following:

>
/home/martijn/virtualenv/eggs/SQLAlchemy-1.1.0b1-py2.7-linux-x86_64.egg/sqlalchemy/ext/compiler.py(459)__call__()
-> raise exc.CompileError(
(Pdb) l
454 if not fn:
455 try:
456 fn = self.specs['default']
457 except KeyError:
458 import pdb; pdb.set_trace()
459  -> raise exc.CompileError(
460 "%s construct has no default "
461 "compilation handler." % type(element))
462 return fn(element, compiler, **kw)
[EOF]
(Pdb) p locals()
{'self': ,
 'element': ARRAY(String()),
 'kw': {'type_expression': Column('reference', ARRAY(String()),
table=, primary_key=True, nullable=False,
server_default=DefaultClause('{}', for_update=False))},
 'pdb': ,
 'fn': None,
 'compiler': }
(Pdb) p self.specs
{'sqlite': }
(Pdb) p self.specs['default']
*** KeyError: KeyError('default',)

That sqlite reference looks a bit weird, did I miss some initialisation
somewhere?

Hope this helps,
-- 
Martijn van Oosterhout  http://svana.org/kleptog/

-- 
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.


c
Description: Binary data


Re: [sqlalchemy] 1.1.0b1: construct has no default compilation handler.

2016-06-27 Thread Mike Bayer
Not really sure, that URL itself won't allow a psycopg2 connection to 
even occur.   The error means that the construct is trying to be 
generated as a string, like in a print statement.   But 1.1 has a new 
feature that allows default stringification of pg.ARRAY and other 
constructs to actually work.


Need a stack trace at the very least.



On 06/27/2016 08:34 AM, Martijn van Oosterhout wrote:

from sqlalchemy import create_engine, MetaData
from sqlalchemy import Column
from sqlalchemy.dialects.postgresql import ARRAY
from sqlalchemy import String
from sqlalchemy.ext.declarative import declarative_base

metadata = MetaData()
metadata.bind = create_engine('postgresql:///')
Base = declarative_base(metadata=metadata)

class Test(Base):
__tablename__ = 'test'
reference = Column(ARRAY(String), nullable=False,
server_default='{}', primary_key=True)

metadata.create_all(bind=metadata.bind)


--
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] 1.1.0b1: construct has no default compilation handler.

2016-06-27 Thread Martijn van Oosterhout
When trying out 1.1.0b1 (to look at the new events) I got the $SUBJECT 
error from our test cases.

I'm not sure what exactly is going on, because when I run the script below 
line-by-line in the django shell, it breaks, but if I run it from the 
command-line it works. But that's probably more to do with my local setup. 
With 1.0.0 it doesn't fail in either case.


from sqlalchemy import create_engine, MetaData
from sqlalchemy import Column
from sqlalchemy.dialects.postgresql import ARRAY
from sqlalchemy import String
from sqlalchemy.ext.declarative import declarative_base

metadata = MetaData()
metadata.bind = create_engine('postgresql:///')
Base = declarative_base(metadata=metadata)

class Test(Base):
__tablename__ = 'test'
reference = Column(ARRAY(String), nullable=False, server_default='{}', 
primary_key=True)

metadata.create_all(bind=metadata.bind)

===

Hope this helps,
-- 
Martijn van Oosterhout

-- 
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.