sequel-snowflake 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.github/workflows/gem-push.yml +31 -0
- data/.github/workflows/ruby.yml +40 -0
- data/.gitignore +62 -0
- data/.rspec +4 -0
- data/CHANGELOG.md +15 -0
- data/Gemfile +4 -0
- data/LICENSE +19 -0
- data/README.md +75 -0
- data/Rakefile +13 -0
- data/lib/sequel-snowflake.rb +7 -0
- data/lib/sequel-snowflake/version.rb +6 -0
- data/lib/sequel/adapters/snowflake.rb +81 -0
- data/sequel-snowflake.gemspec +27 -0
- data/spec/sequel/adapters/snowflake_spec.rb +71 -0
- data/spec/snowflake_spec.rb +8 -0
- data/spec/spec_helper.rb +10 -0
- metadata +131 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b0b9a03ce3aedfe6db5faa8659e7eb8b13e2507df006ded3fd2e1a3acef9c85f
|
4
|
+
data.tar.gz: c03b76900ba58dc7cc0cf93d3412be9c0bead514c1dab540d289dfab34aa40cb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1bc7b615f16bb2ec666c303aa4688f16f0b41be32406f273b85ddf1c93ac11e2fb759123659d35b4b842781d0d7d9e81b5a1db8541698d8bcdf20f4516c5dcd5
|
7
|
+
data.tar.gz: a53c7946e6775280163066b1dc97026d6444ab3ee79e12e70c951093155d7559347292a040299c76fda2b6a7856f38c0df0465ea059bbb9df3fe88e98df5efa5
|
@@ -0,0 +1,31 @@
|
|
1
|
+
name: Ruby Gem
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ main ]
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
build:
|
9
|
+
name: Build + Publish
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
permissions:
|
12
|
+
contents: read
|
13
|
+
packages: write
|
14
|
+
|
15
|
+
steps:
|
16
|
+
- uses: actions/checkout@v2
|
17
|
+
- name: Set up Ruby 2.6
|
18
|
+
uses: actions/setup-ruby@v1
|
19
|
+
with:
|
20
|
+
ruby-version: 2.6.x
|
21
|
+
|
22
|
+
- name: Publish to RubyGems
|
23
|
+
run: |
|
24
|
+
mkdir -p $HOME/.gem
|
25
|
+
touch $HOME/.gem/credentials
|
26
|
+
chmod 0600 $HOME/.gem/credentials
|
27
|
+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
28
|
+
gem build *.gemspec
|
29
|
+
gem push *.gem
|
30
|
+
env:
|
31
|
+
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Ruby
|
9
|
+
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
branches: [ main ]
|
13
|
+
pull_request:
|
14
|
+
branches: [ main ]
|
15
|
+
|
16
|
+
jobs:
|
17
|
+
test:
|
18
|
+
|
19
|
+
runs-on: ubuntu-latest
|
20
|
+
strategy:
|
21
|
+
matrix:
|
22
|
+
ruby-version: ['2.6', '2.7', '3.0']
|
23
|
+
|
24
|
+
steps:
|
25
|
+
- uses: actions/checkout@v2
|
26
|
+
- name: Install unix-odbc
|
27
|
+
run: sudo apt-get install unixodbc
|
28
|
+
- name: Install Snowflake ODBC driver
|
29
|
+
run: curl ${SNOWFLAKE_DRIVER_URL} -o snowflake_driver.deb && sudo dpkg -i snowflake_driver.deb
|
30
|
+
env:
|
31
|
+
SNOWFLAKE_DRIVER_URL: https://sfc-repo.snowflakecomputing.com/odbc/linux/latest/snowflake-odbc-2.23.2.x86_64.deb
|
32
|
+
- name: Set up Ruby
|
33
|
+
uses: ruby/setup-ruby@v1
|
34
|
+
with:
|
35
|
+
ruby-version: ${{ matrix.ruby-version }}
|
36
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
37
|
+
- name: Run tests
|
38
|
+
run: bundle exec rake
|
39
|
+
env:
|
40
|
+
SNOWFLAKE_CONN_STR: "${{secrets.SNOWFLAKE_CONN_STR}}"
|
data/.gitignore
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
# Used by dotenv library to load environment variables.
|
14
|
+
# .env
|
15
|
+
|
16
|
+
# Ignore Byebug command history file.
|
17
|
+
.byebug_history
|
18
|
+
|
19
|
+
## Specific to RubyMotion:
|
20
|
+
.dat*
|
21
|
+
.repl_history
|
22
|
+
build/
|
23
|
+
*.bridgesupport
|
24
|
+
build-iPhoneOS/
|
25
|
+
build-iPhoneSimulator/
|
26
|
+
|
27
|
+
## Specific to RubyMotion (use of CocoaPods):
|
28
|
+
#
|
29
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
30
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
31
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
32
|
+
#
|
33
|
+
# vendor/Pods/
|
34
|
+
|
35
|
+
## Documentation cache and generated files:
|
36
|
+
/.yardoc/
|
37
|
+
/_yardoc/
|
38
|
+
/doc/
|
39
|
+
/rdoc/
|
40
|
+
|
41
|
+
## Environment normalization:
|
42
|
+
/.bundle/
|
43
|
+
/vendor/bundle
|
44
|
+
/lib/bundler/man/
|
45
|
+
|
46
|
+
# for a library or gem, you might want to ignore these files since the code is
|
47
|
+
# intended to run in multiple environments; otherwise, check them in:
|
48
|
+
Gemfile.lock
|
49
|
+
.ruby-version
|
50
|
+
.ruby-gemset
|
51
|
+
|
52
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
53
|
+
.rvmrc
|
54
|
+
|
55
|
+
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
|
56
|
+
# .rubocop-https?--*
|
57
|
+
|
58
|
+
# Ignore for macOS systems
|
59
|
+
.DS_Store
|
60
|
+
|
61
|
+
# Jetbrains IDEs
|
62
|
+
.idea/
|
data/.rspec
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
### 2.0.0 / 2021-06-16
|
2
|
+
|
3
|
+
* Change LICENSE to MIT (open source).
|
4
|
+
* This gem is now tested against Rubies 2.6, 2.7, and 3.0.
|
5
|
+
|
6
|
+
|
7
|
+
### 1.0.0 / 2021-04-22 [Initial Release]
|
8
|
+
|
9
|
+
* Handle parsing Snowflake values for the following types:
|
10
|
+
* Numeric data types
|
11
|
+
* String data types
|
12
|
+
* Booleans
|
13
|
+
* Dates
|
14
|
+
* Support insertion of multiple rows using the `VALUES` syntax.
|
15
|
+
* Support creating tables with `String` columns with maximum varchar size (16777216).
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2021 Yesware, Inc.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
# sequel-snowflake
|
2
|
+
|
3
|
+
An adapter to connect to Snowflake databases using [Sequel](http://sequel.jeremyevans.net/).
|
4
|
+
This provides proper types for returned values, as opposed to the ODBC adapter.
|
5
|
+
|
6
|
+
[](https://github.com/Yesware/sequel-snowflake/actions/workflows/ruby.yml)
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
gem 'sequel-snowflake'
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle install
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install sequel-snowflake
|
21
|
+
|
22
|
+
You'll also need [unixODBC](http://www.unixodbc.org/) (if on Linux/macOS) and the appropriate
|
23
|
+
[Snowflake ODBC driver](https://sfc-repo.snowflakecomputing.com/odbc/index.html) in order to use
|
24
|
+
this adapter. Follow the Snowflake documentation on their ODBC Driver
|
25
|
+
[here](https://docs.snowflake.com/en/user-guide/odbc.html) before proceeding.
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
When establishing the connection, specify `:snowflake` as the adapter to use.
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
DB = Sequel.connect(adapter: :snowflake,
|
33
|
+
drvconnect: conn_str)
|
34
|
+
```
|
35
|
+
|
36
|
+
## Testing
|
37
|
+
|
38
|
+
In order to run specs, you'll need a Snowflake account. A connection string should be
|
39
|
+
provided as an environment variable `SNOWFLAKE_CONN_STR`. For example, on macOS,
|
40
|
+
our connection string would resemble:
|
41
|
+
|
42
|
+
```bash
|
43
|
+
DRIVER=/opt/snowflake/snowflakeodbc/lib/universal/libSnowflake.dylib;
|
44
|
+
SERVER=<account>.<region>.snowflakecomputing.com;
|
45
|
+
DATABASE=<database>;
|
46
|
+
WAREHOUSE=<warehouse>;
|
47
|
+
SCHEMA=<schema>;
|
48
|
+
UID=<user>;
|
49
|
+
PWD=<password>;
|
50
|
+
CLIENT_SESSION_KEEP_ALIVE=true;
|
51
|
+
```
|
52
|
+
|
53
|
+
The test will create a temporary table on the specified database to run tests on, and this will
|
54
|
+
be taken down either via the `after(:each)` blocks or when the connection is closed.
|
55
|
+
|
56
|
+
## GitHub Actions
|
57
|
+
|
58
|
+
We have two workflows included in this project:
|
59
|
+
|
60
|
+
* Ruby (`ruby.yml`): This runs the specs for this gem against Ruby 2.6, 2.7, and 3.0. Note
|
61
|
+
that this requires the secret `SNOWFLAKE_CONN_STR` to be set (see above for example connection string),
|
62
|
+
as we need to connect to Snowflake to run tests. These specs will be run for every pull request,
|
63
|
+
and is run after every commit to those branches.
|
64
|
+
|
65
|
+
* Ruby Gem (`gem-push.yml`): This builds and pushes this gem to RubyGems, acting only on successful
|
66
|
+
pushes to the `main` branch. Note that this workflow requires a `RUBYGEMS_AUTH_TOKEN` secret to be set
|
67
|
+
to authenticate with RubyGems.
|
68
|
+
|
69
|
+
## Contributing
|
70
|
+
|
71
|
+
1. Fork it ( https://github.com/Yesware/sequel-snowflake/fork )
|
72
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
73
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
74
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
75
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require 'bundler/gem_tasks'
|
3
|
+
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
|
6
|
+
RSpec::Core::RakeTask.new
|
7
|
+
|
8
|
+
desc 'Run specs'
|
9
|
+
task :test => :spec
|
10
|
+
task :default => :spec
|
11
|
+
|
12
|
+
desc 'All-in-one target for CI servers to run.'
|
13
|
+
task :ci => ['spec']
|
@@ -0,0 +1,7 @@
|
|
1
|
+
require 'sequel-snowflake/version'
|
2
|
+
require 'sequel/adapters/snowflake'
|
3
|
+
|
4
|
+
# Register our Snowflake adapter to Sequel's map.
|
5
|
+
# This allows us to specify the adapter on database connection:
|
6
|
+
# DB = Sequel.connect(adapter: :snowflake, ...)
|
7
|
+
Sequel::ADAPTER_MAP[:snowflake] = Sequel::Snowflake::Database
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'sequel'
|
2
|
+
require 'sequel/adapters/odbc'
|
3
|
+
|
4
|
+
# A lightweight adapter providing Snowflake support for the `sequel` gem.
|
5
|
+
# The only difference between this and the Sequel-provided ODBC adapter is
|
6
|
+
# how we interpret the response data, which is handled by the Dataset class.
|
7
|
+
module Sequel
|
8
|
+
module Snowflake
|
9
|
+
class Database < Sequel::ODBC::Database
|
10
|
+
# Default varchar size is the maximum (https://docs.snowflake.com/en/sql-reference/data-types-text.html#varchar)
|
11
|
+
def default_string_column_size
|
12
|
+
16777216
|
13
|
+
end
|
14
|
+
|
15
|
+
def dataset_class_default
|
16
|
+
Sequel::Snowflake::Dataset
|
17
|
+
end
|
18
|
+
private :dataset_class_default
|
19
|
+
end
|
20
|
+
|
21
|
+
# A custom Sequel Dataset class crafted specifically to handle Snowflake results.
|
22
|
+
class Dataset < Sequel::ODBC::Dataset
|
23
|
+
def fetch_rows(sql)
|
24
|
+
execute(sql) do |s|
|
25
|
+
i = -1
|
26
|
+
cols = s.columns(true).map{|c| [output_identifier(c.name), c.type, c.scale, i+=1]}
|
27
|
+
columns = cols.map{|c| c[0]}
|
28
|
+
self.columns = columns
|
29
|
+
s.each do |row|
|
30
|
+
hash = {}
|
31
|
+
cols.each{|n,type,scale,j| hash[n] = convert_snowflake_value(row[j], type, scale)}
|
32
|
+
yield hash
|
33
|
+
end
|
34
|
+
end
|
35
|
+
self
|
36
|
+
end
|
37
|
+
|
38
|
+
# This is similar to the ODBC adapter's Dataset#convert_odbc_value, except for some special casing
|
39
|
+
# around Snowflake numerics, which come in through ODBC as Strings instead of Numbers.
|
40
|
+
# In those cases, we need to examine the column type as well as the scale,
|
41
|
+
# to properly convert Integers and Doubles.
|
42
|
+
# Partially inspired by https://github.com/instacart/odbc_adapter.
|
43
|
+
#
|
44
|
+
# @param value The actual value to be converted
|
45
|
+
# @param column_type The type assigned to that value's column
|
46
|
+
# @param scale [Number] The number of digits to the right of the decimal point, if this is a SQL_DECIMAL value.
|
47
|
+
def convert_snowflake_value(value, column_type, scale)
|
48
|
+
return nil if value.nil? # Null values need no conversion.
|
49
|
+
|
50
|
+
case value
|
51
|
+
when ::ODBC::TimeStamp
|
52
|
+
db.to_application_timestamp(
|
53
|
+
[value.year, value.month, value.day, value.hour, value.minute, value.second, value.fraction]
|
54
|
+
)
|
55
|
+
when ::ODBC::Time
|
56
|
+
Sequel::SQLTime.create(value.hour, value.minute, value.second)
|
57
|
+
when ::ODBC::Date
|
58
|
+
Date.new(value.year, value.month, value.day)
|
59
|
+
else
|
60
|
+
if column_type == ::ODBC::SQL_BIT
|
61
|
+
value == 1
|
62
|
+
elsif column_type == ::ODBC::SQL_DECIMAL && scale.zero?
|
63
|
+
value.to_i
|
64
|
+
elsif column_type == ::ODBC::SQL_DECIMAL && !scale.zero?
|
65
|
+
value.to_f
|
66
|
+
else
|
67
|
+
# Ensure strings are in UTF-8: https://stackoverflow.com/q/65946886
|
68
|
+
value.is_a?(String) ? value.force_encoding('UTF-8') : value
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
private :convert_snowflake_value
|
73
|
+
|
74
|
+
# Snowflake can insert multiple rows using VALUES (https://stackoverflow.com/q/64578007)
|
75
|
+
def multi_insert_sql_strategy
|
76
|
+
:values
|
77
|
+
end
|
78
|
+
private :multi_insert_sql_strategy
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'sequel-snowflake/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "sequel-snowflake"
|
8
|
+
spec.version = Sequel::Snowflake::VERSION
|
9
|
+
spec.authors = ["Yesware, Inc"]
|
10
|
+
spec.email = ["engineering@yesware.com"]
|
11
|
+
spec.summary = %q{Sequel adapter for Snowflake}
|
12
|
+
spec.description = spec.summary
|
13
|
+
spec.homepage = "https://github.com/Yesware/sequel-snowflake"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
|
21
|
+
spec.add_runtime_dependency 'sequel'
|
22
|
+
spec.add_runtime_dependency 'ruby-odbc'
|
23
|
+
|
24
|
+
spec.add_development_dependency 'rake'
|
25
|
+
spec.add_development_dependency 'rspec'
|
26
|
+
spec.add_development_dependency 'simplecov'
|
27
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'securerandom'
|
2
|
+
|
3
|
+
describe Sequel::Snowflake::Dataset do
|
4
|
+
describe 'Converting Snowflake data types' do
|
5
|
+
# Create a test table with a reasonably-random suffix
|
6
|
+
let!(:test_table) { "SEQUEL_SNOWFLAKE_SPECS_#{SecureRandom.hex(10)}".to_sym }
|
7
|
+
let!(:db) { Sequel.connect(adapter: :snowflake, drvconnect: ENV['SNOWFLAKE_CONN_STR']) }
|
8
|
+
|
9
|
+
before(:each) do
|
10
|
+
# Set timezone for parsing timestamps. This gives us a consistent timezone to test against below.
|
11
|
+
Sequel.default_timezone = :utc
|
12
|
+
|
13
|
+
db.create_table(test_table, :temp => true) do
|
14
|
+
Numeric :n
|
15
|
+
BigDecimal :d, size: [38, 5]
|
16
|
+
Float :f
|
17
|
+
DateTime :t
|
18
|
+
TrueClass :b
|
19
|
+
String :str
|
20
|
+
String :str2
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
after(:each) do
|
25
|
+
db.drop_table(test_table)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'converts Snowflake data types into equivalent Ruby types' do
|
29
|
+
db[test_table].insert(
|
30
|
+
{ n: 17, d: 42.035, f: 1.2247, t: '2020-03-12 01:02:03.123456789', b: true, str: 'hi', str2: nil }
|
31
|
+
)
|
32
|
+
|
33
|
+
res = db[test_table].select(
|
34
|
+
:n, :d, :f, :t, :b,
|
35
|
+
Sequel.as(Sequel.function(:to_time, :t), :time),
|
36
|
+
Sequel.as(Sequel.function(:to_date, :t), :date),
|
37
|
+
:str, :str2
|
38
|
+
).first
|
39
|
+
|
40
|
+
expect(res).to include(
|
41
|
+
n: 17,
|
42
|
+
d: a_value_within(0.0001).of(42.035),
|
43
|
+
f: a_value_within(0.00001).of(1.2247),
|
44
|
+
b: true,
|
45
|
+
str: 'hi',
|
46
|
+
str2: nil
|
47
|
+
)
|
48
|
+
|
49
|
+
expect(res[:t]).to be_a(Time)
|
50
|
+
expect(res[:t].iso8601).to eq('2020-03-12T01:02:03Z')
|
51
|
+
|
52
|
+
expect(res[:time]).to be_a(Time)
|
53
|
+
expect(res[:time].to_s).to eq('01:02:03')
|
54
|
+
|
55
|
+
expect(res[:date]).to be_a(Date)
|
56
|
+
expect(res[:date].to_s).to eq('2020-03-12')
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'inserts multiple records successfully using the VALUE syntax' do
|
60
|
+
db[test_table].multi_insert(
|
61
|
+
[
|
62
|
+
{ n: 17, d: 42.035, f: 1.2247, t: '2020-03-12 01:02:03.123456789', b: true, str: 'hi', str2: nil },
|
63
|
+
{ n: 18, d: 837.5, f: 3.09, t: '2020-03-15 11:22:33.12345', b: false, str: 'beware the ides', str2: 'of march' }
|
64
|
+
]
|
65
|
+
)
|
66
|
+
|
67
|
+
expect(db[test_table].count).to eq(2)
|
68
|
+
expect(db[test_table].select(:n).all).to eq([{ n: 17 }, { n: 18 }])
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sequel-snowflake
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yesware, Inc
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-06-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sequel
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: ruby-odbc
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Sequel adapter for Snowflake
|
84
|
+
email:
|
85
|
+
- engineering@yesware.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".github/workflows/gem-push.yml"
|
91
|
+
- ".github/workflows/ruby.yml"
|
92
|
+
- ".gitignore"
|
93
|
+
- ".rspec"
|
94
|
+
- CHANGELOG.md
|
95
|
+
- Gemfile
|
96
|
+
- LICENSE
|
97
|
+
- README.md
|
98
|
+
- Rakefile
|
99
|
+
- lib/sequel-snowflake.rb
|
100
|
+
- lib/sequel-snowflake/version.rb
|
101
|
+
- lib/sequel/adapters/snowflake.rb
|
102
|
+
- sequel-snowflake.gemspec
|
103
|
+
- spec/sequel/adapters/snowflake_spec.rb
|
104
|
+
- spec/snowflake_spec.rb
|
105
|
+
- spec/spec_helper.rb
|
106
|
+
homepage: https://github.com/Yesware/sequel-snowflake
|
107
|
+
licenses: []
|
108
|
+
metadata: {}
|
109
|
+
post_install_message:
|
110
|
+
rdoc_options: []
|
111
|
+
require_paths:
|
112
|
+
- lib
|
113
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
requirements: []
|
124
|
+
rubygems_version: 3.0.3.1
|
125
|
+
signing_key:
|
126
|
+
specification_version: 4
|
127
|
+
summary: Sequel adapter for Snowflake
|
128
|
+
test_files:
|
129
|
+
- spec/sequel/adapters/snowflake_spec.rb
|
130
|
+
- spec/snowflake_spec.rb
|
131
|
+
- spec/spec_helper.rb
|