Sha256: 2c9c09234c26e7e2203c54dc91b52425d2ec27b3fa0d337817ff403639b92fa6

Contents?: true

Size: 687 Bytes

Versions: 1

Compression:

Stored size: 687 Bytes

Contents

# frozen_string_literal: true

require_relative '../ext'
import('../../lib/eno/pg')

require 'pp'

class PostgresTest < T
  DB = PG.connect(
    host:     '/tmp',
    user:     'reality',
    password: nil,
    dbname:   'reality',
    sslmode:  'require'
  )

  def test_correct_escaping
    results = DB.q {
      select _l("abc def 'ghi'\n").as(:"jkl mno")
    }.to_a
    assert_equal(1, results.size)
    assert_equal(['jkl mno'], results.first.keys)
    assert_equal(["abc def 'ghi'\n"], results.first.values)
  end

  def test_identifier_escaping
    query = Q {
      select _i("abc'def\"ghi")
    }
    assert_equal("select \"abc'def\"\"ghi\"", DB.query_to_sql(query))
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eno-0.5 test/adapters/test_pg.rb