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

docs are wrong on parameters? #72

Open
nicferrier opened this issue Nov 28, 2017 · 3 comments
Open

docs are wrong on parameters? #72

nicferrier opened this issue Nov 28, 2017 · 3 comments

Comments

@nicferrier
Copy link

Are the docs wrong on parameters?

for example:

def query_one(query, *args, &block : ResultSet -> U) : U forall U

I'm using 0.4.1 shard and had to use $x (eg: $1) for params and not ?.

Is this right or am I confused?

@bcardiff
Copy link
Member

Hi @nicferrier . Is a duplicate of #30 .
crystal-db does not touch the sql statement, so it depends on each driver.
Adding that note to every example seems wrong, but clearly the question will keep coming 💭

@rurounijones
Copy link

Checking in as another person who was confused and lost quite a lot of time on this.

@straight-shoota
Copy link
Member

Maybe it would already help to make the individual examples self-contained, so the reader can see that it is for a MySQL database:

MySQL::Database.open(ENV["DATABASE_URL"]) do |db|
  name = db.query_one "select name from contacts where id = ?", 18, &.read(String)
end

Still, a note about different parameter syntax depending on the database system should better be added to every method accepting arguments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants