Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

For purposes other than talking to the database, eg. printing exemplary SQL statements to the screen. A tentative sketch:

# Object
class Object
  def to_sql
    case self
    when Numeric then self
    when NilClass then 'null'
    when String
      if encoding == Encoding::ASCII_8BIT
        format "x'%s'", unpack1('H*')
      else
        format "'%s'", gsub('\\', '\&\&').gsub("'", "''")
      end
    else
      raise ArgumentError, "No quoting implemented for #{self.class} (#{self})"
    end
  end
end
You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
💡
Ideas
Labels
None yet
1 participant
Converted from issue

This discussion was converted from issue #713 on June 16, 2026 13:53.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.