Comments (13)
@lukas-gitl this is awesome! I can make it into a proper pull request and see how to integrate it. thank you so much!
from sqlalchemy-citext.
There is a better way to make CITEXT work with arrays. If CITEXT[]
is registered as an array type in psycopg2, then everything works just fine without any monkey patching. That can be accomplished with that snippet:
def register_citext_array(engine):
results = engine.execute(text("SELECT typarray FROM pg_type WHERE typname = 'citext'"))
oids = tuple(row[0] for row in results)
array_type = psycopg2.extensions.new_array_type(oids, b'citext[]', psycopg2.STRING)
psycopg2.extensions.register_type(array_type, None)
It would be great to include something about it to README.
from sqlalchemy-citext.
Would be great to get this into this project somehow.
from sqlalchemy-citext.
@lukas-gitl or..you can take a stab at a PR? :)
from sqlalchemy-citext.
Edited initial post with small fix for stripping quotes
from sqlalchemy-citext.
Updated it again to use csv. This seems to solve all issues here.
from sqlalchemy-citext.
@lukas-gitl thanks for this! I'll get to it this weekend.
from sqlalchemy-citext.
Hi! Any hopes for releasing this fix?
from sqlalchemy-citext.
@rmihael Thanks!!! Works great except that for me psycopg2 told me it expected b'citext[]'
as a regular string (not bytes): 'citext[]'
.
from sqlalchemy-citext.
It looks like this works now
On a related note- I stumbled upon this issue while trying to make sqlacodegen
produce CIText
and CIText[]
columns. I ended up using sqlalchemy-citext to do it. It works well and was a very, very small patch. Please see agronholm/sqlacodegen#125 if you use sqlacodegen
and want CIText
and CIText[]
support
from sqlalchemy-citext.
I wonder if this can be closed now as it seems to be working
from sqlalchemy-citext.
I will update the README! Thanks
from sqlalchemy-citext.
@mahmoudimus I sent #19 which is the register function that @rmihael suggested. I tested this on CPython 3.7 and it works well, fixes the problem of getting back characters instead of strings. It needs to be explicitly called, so in theory it shouldn't break anyone who isn't explicitly using it
from sqlalchemy-citext.
Related Issues (15)
- column.type is NullType HOT 1
- KeyError for the citext field HOT 4
- The version specified ('1.5_0') is an invalid version HOT 4
- Quering against literal values doesn't always work HOT 1
- FYI: PR in to sqlacodegen HOT 1
- Feature Request: Compatibility with AsyncPG
- Changes required for sqlalchemy 2.x / sqlalchemy 1.4 with future Engine HOT 2
- SAWarning in cache key for CIText() HOT 5
- Support psycopg3
- Hard psycopg2 dependency is still breaking pypy HOT 1
- UserDefinedType CIText() will not produce a cache key because the ``cache_ok`` attribute is not set to True HOT 2
- Don't depend on psycopg2 HOT 8
- Create changelog
- How to use with table reflections HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sqlalchemy-citext.