Skip to content

Prepared statements don't support true/false arguments properly #775

@jeremyevans

Description

@jeremyevans

It results in BigDecimal 0 for both:

client.prepare('SELECT ? as a').execute(true).to_a.first[:a]
# /usr/local/lib/ruby/gems/2.3/gems/mysql2-0.4.4/lib/mysql2/statement.rb:8: warning: :cache_rows is forced for prepared statements (if not streaming)
# => #<BigDecimal:88803c38,'0.0',9(18)>
client.prepare('SELECT ? as a').execute(false).to_a.first[:a]
# /usr/local/lib/ruby/gems/2.3/gems/mysql2-0.4.4/lib/mysql2/statement.rb:8: warning: :cache_rows is forced for prepared statements (if not streaming)
# => #<BigDecimal:7e32c4a8,'0.0',9(18)>

I think the best behavior would be to treat true as 1 and false as 0, though I could understand raising an exception if you don't want to handle them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions