Giter Club home page Giter Club logo

Comments (9)

atombender avatar atombender commented on July 23, 2024 15

I also expected Where and JoinΒ to accept subqueries. E.g.:

sqlBuilder.
  Select("id").
  From("documents").
  Where(squirrel.Eq("id": sqlBuilder.
    Select("source_id").
    From("refs").
    Where(squirrel.Eq{"target_id", ids})))

This issue hasn't received any love since 2014. Seems Squirrel doesn't have much activity.

from squirrel.

ranfdev avatar ranfdev commented on July 23, 2024 8

If you use squirrel and postgres, you probably have something like this

var psql = sq.StatementBuilder.PlaceholderFormat(sq.Dollar)

in your code.

Don't use that when writing code which uses subqueries. Instead, simply use squirrel directly.

query := sq.Select()....

Then, just before calling .ToSql(), convert the placeholders:

sql, args, err := query.PlaceholderFormat(sq.Dollar).ToSql()

from squirrel.

ddemoss222 avatar ddemoss222 commented on July 23, 2024 5

Any fix for SelectFrom since this was closed? I am having problems passing arguments using select from and postgres. I keep getting pq: got 1 parameters but the statement requires 0. Workarounds would be satisfactory as well. Thanks!

from squirrel.

lann avatar lann commented on July 23, 2024

This main problem with this and #20 is handling Postgres placeholders. Postgres needs to have unique placeholders (e.g. $1, $2, $3), which is difficult to achieve when combining multiple queries in the current code.

from squirrel.

umisama avatar umisama commented on July 23, 2024

In my view, It works well with change timing PlaceholderFormat.Placeholders() in selectData.ToSql().
Can I write prototype?

from squirrel.

lann avatar lann commented on July 23, 2024

Go for it. If it works I'll be happy to accept.

from squirrel.

umisama avatar umisama commented on July 23, 2024

I tried fix this issue on fffd5d6.
I changed SelectBuilder.From() to acceptable SelectBuilder type.

thanks!

from squirrel.

elgris avatar elgris commented on July 23, 2024

Hi guys! You can also check alternative with no additional builders implementation ;)
https://github.com/elgris/sqrl
If it looks good, I can prepare PR for squirrel.

from squirrel.

tbarbugli avatar tbarbugli commented on July 23, 2024

AFAIK this is supported with SelectFrom which does not support parameters correctly

from squirrel.

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.