Skip to content

Using binary data #54

@bryanp

Description

@bryanp

I'm using mini_sql to query a bytea column in postgres, but I'm having trouble getting the query to run. Here's the error:

PG::CharacterNotInRepertoire:
  ERROR:  invalid byte sequence for encoding "UTF8": 0xe1 0x46 0xe0

Using pg directly, I can do something like this:

sql = <<~SQL
  select from secrets where key = $1
SQL

db.exec_params(sql, [
  {value: SecureRandom.bytes(32), format: 1},
])

However I'm not too sure the best way to go about solving this using mini_sql. Note that I can get the same PG::CharacterNotInRepertoire error using pg directly with the following approach:

sql = <<~SQL
  select from secrets where key = '#{SecureRandom.bytes(32)}'
SQL

db.exec(sql)

Curious if there's a way around this issue or if additional support is needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions