Coder Social home page Coder Social logo

Comments (5)

dbussink avatar dbussink commented on August 19, 2024

If you want to use byte array's directly, you have to wrap the string in a ByteArray object:

conn.create_command("INSERT INTO bob (salt) VALUES (?)").execute_non_query(::Extlib::ByteArray("FJ\\"))

This is needed because PostgreSQL needs different escaping for strings and binary data, so the driver needs to be able to discern between these. This is done with this separate type.

from do.

d11wtq avatar d11wtq commented on August 19, 2024

Ah, I see, that makes sense, thanks!

BTW, any reason you're not just using prepared statements with bind values at the C API level?

from do.

dbussink avatar dbussink commented on August 19, 2024

It doesn't support all the cases we want to support for various Ruby types. I've thought about it a few times but haven't come up with a satisfactory approach yet.

from do.

d11wtq avatar d11wtq commented on August 19, 2024

That's a shame, because it saves a lot of headaches and is a bit less hacky than doing string substitutions.

from do.

dbussink avatar dbussink commented on August 19, 2024

It is, but it's actually the reason that a lot of database drivers have their own logic for it (for example all the Perl database drivers do it themselves too).

Another problem is that DO tries to unify the API's of different database drivers, and all the differences in prepared statement API's of databases doesn't help there either.

from do.

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.