Sha256: 55a5af86baed042aaf8a2897ee042dc931d143dfd3b41b1cb771637390afb676

Contents?: true

Size: 1.14 KB

Versions: 20

Compression:

Stored size: 1.14 KB

Contents

require 'test_helper'

class QuotingTest < Test::Unit::TestCase

  def test_quote_identifier
    assert_equal '"test"', Vertica.quote_identifier(:test)
    assert_equal '"te""st"', Vertica.quote_identifier('te"st')
    assert_equal '"te""""st"', Vertica.quote_identifier('te""st')
  end

  def test_quote
    assert_equal "'test'", Vertica.quote('test')
    assert_equal "'te''st'", Vertica.quote("te'st")
    assert_equal "'te''''st'", Vertica.quote("te''st")
    assert_equal "'test'", Vertica.quote(:test)

    assert_equal 'NULL', Vertica.quote(nil)
    assert_equal 'TRUE', Vertica.quote(true)
    assert_equal 'FALSE', Vertica.quote(false)

    assert_equal '1', Vertica.quote(1)
    assert_equal '1.1', Vertica.quote(1.1)
    assert_equal '1.1', Vertica.quote(BigDecimal.new('1.1'))

    assert_equal "'2010-02-27'::date", Vertica.quote(Date.parse('2010-02-27'))
    assert_equal "'2010-02-27 12:44:25'::timestamp", Vertica.quote(DateTime.parse('2010-02-27 12:44:25'))
    assert_equal "'2010-02-27 12:44:25'::timestamp", Vertica.quote(Time.utc(2010,2, 27, 12, 44, 25))
    
    assert_equal "NULL, 1, TRUE, 'test'", Vertica.quote([nil, 1, true, 'test'])
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
vertica-0.11.0 test/unit/quoting_test.rb
vertica-0.10.5 test/unit/quoting_test.rb
vertica-0.10.4 test/unit/quoting_test.rb
vertica-0.10.3 test/unit/quoting_test.rb
vertica-0.10.2 test/unit/quoting_test.rb
vertica-0.10.1 test/unit/quoting_test.rb
vertica-0.10.0 test/unit/quoting_test.rb
vertica-0.9.6 test/unit/quoting_test.rb
vertica-0.9.5 test/unit/quoting_test.rb
vertica-0.9.4 test/unit/quoting_test.rb
vertica-0.9.3 test/unit/quoting_test.rb
vertica-0.9.2 test/unit/quoting_test.rb
vertica-0.9.1 test/unit/quoting_test.rb
vertica-0.9.0 test/unit/quoting_test.rb
vertica-0.9.0.beta9 test/unit/quoting_test.rb
vertica-0.9.0.beta8 test/unit/quoting_test.rb
vertica-0.9.0.beta7 test/unit/quoting_test.rb
vertica-0.9.0.beta6 test/unit/quoting_test.rb
vertica-0.9.0.beta5 test/unit/quoting_test.rb
vertica-0.9.0.beta4 test/unit/quoting_test.rb