Sha256: a1b18b6bf1115f9d913e820d7cda922d14f77eaf9882522927c8e58b49ef95f5

Contents?: true

Size: 792 Bytes

Versions: 79

Compression:

Stored size: 792 Bytes

Contents

require("cipherstash-pg")
db = CipherStashPG.connect(:dbname => "test")
db.exec("DROP TABLE IF EXISTS test")
db.exec("CREATE TABLE test (a INTEGER, b BYTEA)")
a = 42
b = [1, 2, 3]
db.exec("INSERT INTO test(a, b) VALUES($1::int, $2::bytea)", [a, { :value => b.pack("N*"), :format => 1 }])
db.exec("SELECT a::int, b::bytea FROM test LIMIT 1", [], 1) do |res|
  res.nfields.times do |i|
    puts(("Field %d is: %s, a %s (%s) column from table %p" % [i, res.fname(i), db.exec("SELECT format_type($1,$2)", [res.ftype(i), res.fmod(1)]).getvalue(0, 0), res.fformat(i).zero? ? ("string") : ("binary"), res.ftable(i)]))
  end
  res.each do |row|
    puts("a = #{row["a"].inspect}")
    puts("a (unpacked) = #{row["a"].unpack("N*").inspect}")
    puts("b = #{row["b"].unpack("N*").inspect}")
  end
end

Version data entries

79 entries across 79 versions & 1 rubygems

Version Path
cipherstash-pg-1.0.0.beta.16-x86_64-darwin ./sample/test_binary_values.rb
cipherstash-pg-1.0.0.beta.16-x86_64-linux ./sample/test_binary_values.rb
cipherstash-pg-1.0.0.beta.16-arm64-darwin ./sample/test_binary_values.rb
cipherstash-pg-1.0.0.beta.16-aarch64-linux ./sample/test_binary_values.rb
cipherstash-pg-1.0.0.beta.15-x86_64-linux ./sample/test_binary_values.rb
cipherstash-pg-1.0.0.beta.15-aarch64-linux ./sample/test_binary_values.rb
cipherstash-pg-1.0.0.beta.15-arm64-darwin ./sample/test_binary_values.rb
cipherstash-pg-1.0.0.beta.15-x86_64-darwin ./sample/test_binary_values.rb
cipherstash-pg-1.0.0.beta.14-arm64-darwin ./sample/test_binary_values.rb
cipherstash-pg-1.0.0.beta.14-x86_64-linux ./sample/test_binary_values.rb
cipherstash-pg-1.0.0.beta.14-aarch64-linux ./sample/test_binary_values.rb
cipherstash-pg-1.0.0.beta.14-x86_64-darwin ./sample/test_binary_values.rb
cipherstash-pg-1.0.0.beta.13-x86_64-linux ./sample/test_binary_values.rb
cipherstash-pg-1.0.0.beta.13-x86_64-darwin ./sample/test_binary_values.rb
cipherstash-pg-1.0.0.beta.13-arm64-darwin ./sample/test_binary_values.rb
cipherstash-pg-1.0.0.beta.13-aarch64-linux ./sample/test_binary_values.rb
cipherstash-pg-1.0.0.beta.12-x86_64-linux ./sample/test_binary_values.rb
cipherstash-pg-1.0.0.beta.12-x86_64-darwin ./sample/test_binary_values.rb
cipherstash-pg-1.0.0.beta.12-arm64-darwin ./sample/test_binary_values.rb
cipherstash-pg-1.0.0.beta.12-aarch64-linux ./sample/test_binary_values.rb