Sha256: a6ffad97987c7b3cb1ecab573e681ac97b0868773210a4aa167538863922b02e

Contents?: true

Size: 835 Bytes

Versions: 4

Compression:

Stored size: 835 Bytes

Contents

require 'spec_helper'
require 'libsql/sqlite3'
require 'rbconfig'

describe "::Libsql handles the JSON extension" do
  it "can parse a `json_each` call" do
    db = ::Libsql::Database.new( ":memory:" )
    values = %w[ a b c d e f g ]
    db.execute("CREATE TABLE jtest(id, json)")
    db.execute("INSERT INTO jtest(id, json) values (1, json($json))", { "$json" => values })
    rows = db.execute("SELECT jtest.id as i, value as v FROM jtest, json_each(jtest.json)")

    rows.size.should eq(values.size)
  end

  it "can return a proper json column" do
    db = ::Libsql::Database.new( ":memory:" )
    values = %w[ a b c d e f g ]
    db.execute("CREATE TABLE jtest(id INTEGER, json JSON)")
    db.execute("INSERT INTO jtest(id, json) values (1, json($json))", { "$json" => values })

    db.execute("select * from jtest")
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
libsql-0.1.0-x64-mingw-ucrt spec/json_spec.rb
libsql-0.1.0-x64-mingw32 spec/json_spec.rb
libsql-0.1.0-x86-mingw32 spec/json_spec.rb
libsql-0.1.0 spec/json_spec.rb