test_conversion (PostgresTestCase)

    # File tests/tc_postgres.rb, line 14
      def test_conversion
        query = "select true as true_value,\nfalse as false_value,\n$1::bytea as bytea_value,\n'2005-11-30'::date as date_value,\n'12:00:00'::time as time_value,\n'2005-11-30 12:00:00'::timestamp as date_time_value,\n1.5::float as float_value,\n12345.5678::numeric as numeric_value,\n1234.56::numeric(10) as numeric_10_value,\n12345.12345::numeric(10,5) as numeric_10_5_value\n"
        res = @conn.exec(query, "12345\0TEST")
        assert_equal(1, res.num_tuples, 1)
        assert_equal(10, res.num_fields, 10)
        tuple = res.result.first
        assert_equal(true, tuple['true_value'])
        assert_equal(false, tuple['false_value'])
        assert_equal("12345\0TEST", tuple['bytea_value'])
        assert_equal(Date.parse('2005-11-30'), tuple['date_value'])
        assert_equal(Time.parse('12:00:00'), tuple['time_value'])
        assert_equal(Time.parse('2005-11-30 12:00:00'), tuple['date_time_value'])
        assert_equal(1.5, tuple['float_value'])
        assert_equal(BigDecimal("12345.5678"), tuple['numeric_value'])
        assert_equal(1235, tuple['numeric_10_value'])
        assert_kind_of(Integer, tuple['numeric_10_value'])
        assert_equal(BigDecimal("12345.12345"), tuple['numeric_10_5_value'])
      end