Code Monkey home page Code Monkey logo

Comments (4)

dvarrazzo avatar dvarrazzo commented on May 30, 2024

Hello, thank you for looking into this.

Have you started from where I left? Just to know if this is one of the differences I had already tackled or if it was ahead.

The problem behind this specific cast is because text is - unexpectedly - passed as unknown, not as text, by psycopg3. The reason is explained here I didn't expect this failure though: I checked why, and it's likely because concat() arguments are defined as VARIADIC any in Postgres, not as text.

piro=# \df *.concat
                          List of functions
   Schema   |  Name  | Result data type | Argument data types | Type 
------------+--------+------------------+---------------------+------
 pg_catalog | concat | text             | VARIADIC "any"      | func
(1 row)

Most of the time I found these differences I could solve them by making the Django backend create the placeholders with added cast: where the psycopg2 backend generates CONCAT(%s, %s) the psycopg3 one should generate CONCAT(%s::text, %s::text). See this commit for instance: dvarrazzo/django@215d2e3

From a cursory look at my commits in the django repos, things might have changed a bit in psycopg3 since (but not regards this topic: for instance I dropped cursor.callproc()). So if you find anything unexpected please let me know: I'm happy to give support for this Django driver and I appreciate your interest.

Cheers!

from psycopg.

greshilov avatar greshilov commented on May 30, 2024

Thank you for shedding the light on the library behaviour!

I started from dvarrazzo/django@12280d7, which looks like the very last commit in psycopg3 branch.

I created a little PR with proposed CONCAT(%s, %s) -> CONCAT(%s::text, %s::text) conversion: dvarrazzo/django#1. Hope it helps :)

Cheers!

from psycopg.

dvarrazzo avatar dvarrazzo commented on May 30, 2024

Shall we log transformed queries somehow? It would have saved me a lot of time in this case.

Note that you can find query and params as attributes on the cursor, if you need them.

from psycopg.

greshilov avatar greshilov commented on May 30, 2024

Shall we log transformed queries somehow? It would have saved me a lot of time in this case.

Note that you can find query and params as attributes on the cursor, if you need them.

Thanks for the tip!

from psycopg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.