Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wildcard for Postgres #153

Open
nixfreak opened this issue Jun 26, 2022 · 2 comments
Open

Wildcard for Postgres #153

nixfreak opened this issue Jun 26, 2022 · 2 comments

Comments

@nixfreak
Copy link

How would I select * from table using postgres?

By reading the code I was able to actually get the select statements to work using $1

Anyway you can add some docs on using postgres?

Love your library thanks.

@nixfreak nixfreak changed the title Wild card for postres Wildcard for Postgres Jun 26, 2022
@moigagoo
Copy link
Owner

 How would I select * from table using postgres?

select* procs in Norm always select all columns in a given table. If it has relations to other tables, it'll select the related columns as well.

So, every select is a SELECT * essentially :-)

Or maybe I'm misunderstanding your question?

@PhilippMDoerner
Copy link
Collaborator

PhilippMDoerner commented Jul 7, 2022

How would I select * from table using postgres?

By reading the code I was able to actually get the select statements to work using $1

Anyway you can add some docs on using postgres?

Love your library thanks.

Heya,
As moigagoo stated, SELECT * is normal SQL syntax across all databases, so that should always work, regardless of the database.

What you might be meaning by wildcard though (and your usage of $1 indicates that to me), is placeholders, namely stuff like SELECT * FROM some_table WHERE id = ?. That is indeed different between the databases, due to their different query language, with postgres using $1 etc while sqlite uses ?.
I ran into the same issue, so I believe this difference might benefit from some more visibility as well. I've pondered this, but been uncertain as to where it would be best to note this down.

A first "attempt" has already been made to make users aware of this (see #149 and its PR #150), but I myself am not too happy with it, as it might be easily missed.
The main issue I have though is that writing an entire SQLite - Postgres - differences page feels a bit overkill, if all we'll put in there is the different placeholders these databases use. And if we expand that to cover all the syntax differences we'd be repeating the work that has already been done by the very capable people of each database that have written up documentation to cover the database-specific bits and bobs of their syntax.

At a glance I'm not seeing a great solution of where/how to best include that info. Anyone have any suggestions?

@moigagoo moigagoo added this to Norm Jul 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

3 participants