Sha256: f16bb77cdb5a00d345d3e069fc06526fef140c4bee3074509fc1db21b346f68b

Contents?: true

Size: 1.32 KB

Versions: 15

Compression:

Stored size: 1.32 KB

Contents

class TestPostgresBlob < DBDConfig.testbase(:postgresql)
    DATA = "this is my new binary object"

    def test_insert
        assert @dbh
        assert @dbh.ping

        # test with DBI::Binary
        assert_equal 1, @dbh.do("INSERT INTO blob_test (name, data) VALUES (?,?)", "test", DBI::Binary.new(DATA))

        # test with blob_create directly
        blob = @dbh.func(:blob_create, PGconn::INV_WRITE)
        assert blob
        assert @dbh.func(:blob_write, blob, DATA)
        assert_equal 1, @dbh.do("INSERT INTO blob_test (name, data) VALUES (?,?)", "test (2)", blob)

        # test with blob_import directly
        File.open('/tmp/pg_dbi_import_test', 'w') { |f| f << DATA }
        blob = @dbh.func(:blob_import, '/tmp/pg_dbi_import_test')
        assert blob
        assert_equal 1, @dbh.do("INSERT INTO blob_test (name, data) VALUES (?,?)", "test (2)", blob)

        index = 0
        @dbh.select_all("SELECT name, data FROM blob_test") do |name, data|
            index += 1
            assert_equal DATA, @dbh.func(:blob_read, data, DATA.length)
            @dbh.func(:blob_export, data, '/tmp/pg_dbi_read_test')
            assert_equal DATA, File.read('/tmp/pg_dbi_read_test')
        end

        assert_equal 3, index

        File.unlink("/tmp/pg_dbi_read_test")
        File.unlink("/tmp/pg_dbi_import_test")
    end
end

Version data entries

15 entries across 15 versions & 3 rubygems

Version Path
ydbd-pg-0.5.9 test/dbd/postgresql/test_blob.rb
ydbd-pg-0.5.8 test/dbd/postgresql/test_blob.rb
ydbd-pg-0.5.7 test/dbd/postgresql/test_blob.rb
ydbi-0.5.7 test/dbd/postgresql/test_blob.rb
ydbd-pg-0.5.6 test/dbd/postgresql/test_blob.rb
ydbd-pg-0.5.5 test/dbd/postgresql/test_blob.rb
ydbd-pg-0.5.4 test/dbd/postgresql/test_blob.rb
ydbd-pg-0.5.3 test/dbd/postgresql/test_blob.rb
ydbd-pg-0.5.2 test/dbd/postgresql/test_blob.rb
ydbd-pg-0.5.1 test/dbd/postgresql/test_blob.rb
ydbi-0.5.0 test/dbd/postgresql/test_blob.rb
dbd-pg-0.3.9 test/dbd/postgresql/test_blob.rb
dbd-pg-0.3.8 test/dbd/postgresql/test_blob.rb
dbd-pg-0.3.7 test/dbd/postgresql/test_blob.rb
dbd-pg-0.3.6 test/dbd/postgresql/test_blob.rb