clearly some way that you are passing your strings is causing the string itself to be interpreted as an array, rather than the array of strings.
we debug these issues using MCVEs. Below is an MCVE. Verify it works for you, then see if you can tell what's different about your application from this test script.
from sqlalchemy import ARRAY
from sqlalchemy import CHAR
from sqlalchemy import Column
from sqlalchemy import create_engine
from sqlalchemy import Integer
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import Session
Base = declarative_base()
class A(Base):
__tablename__ = 'a'
id = Column(Integer, primary_key=True)
telefone =Column(ARRAY(CHAR(length=14)))
e = create_engine("postgresql://scott:tiger@localhost/test", echo='debug')
Base.metadata.drop_all(e)
Base.metadata.create_all(e)
s = Session(e)
s.add(A(telefone=["(21)11111-1111", "(21)22222-2222"]))
s.commit()
phones = s.query(A.telefone).first().telefone
assert phones == ["(21)11111-1111", "(21)22222-2222"]
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
---
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
Attachments:
- Auto Generated Inline Image 1
- Auto Generated Inline Image 2