sequel-bigquery 0.4.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e444c2d4a5c6b54b5a1bb0efde17e1dd83761ec53f1b796f5e959646bd37f315
4
- data.tar.gz: 41875a2325c00eb26786fbd3ab8430e9880b93d795a18b000bff3dd75ed0ea47
3
+ metadata.gz: c37139c40fd486391d9d16ab147430352b67a1a2b5a55f7eed4189c368b5e87a
4
+ data.tar.gz: e3753842a9727cf53451ff80ac9abc250343a719d4215ab368c5a93a9d2b4830
5
5
  SHA512:
6
- metadata.gz: 725fce3447e58e75c5cf817d736322c567661752d1b2d2f4f45aa0ce712825e8792214d1f56313272d8a84facdadff51f63ee4a6b3bda1b8c55d92a80a826798
7
- data.tar.gz: 3aa8900e8fba7400049e8f83879998b246296e1705d01b25f2a1cf20855cf8faeea09b9d7e4cb7280b2783296d0a27f61ed295275089d6de311c256c5f7ea763
6
+ metadata.gz: 6189f0b53a6edd9d66c915316ce8e9e8c836181609405b54e246c0dbe5451bce995c6f5b73e7b320624c35b62bfd66874757734f839ef7f9023dbc099271b2a4
7
+ data.tar.gz: 715b5adbdb6e225ca9af37363fbc30b59bde54a0b4602d91afcca93506cac541d252b31767571605ee555f2fdaad8d316ccf67a083354bfdcc9cd5f925c51646
data/README.md CHANGED
@@ -13,6 +13,11 @@ Beyond migrations, I'm unsure how useful this gem is. I haven't yet tested what
13
13
  <!-- MarkdownTOC autolink=true -->
14
14
 
15
15
  - [Intro](#intro)
16
+ - [Quirks](#quirks)
17
+ - [Creating tables with column defaults](#creating-tables-with-column-defaults)
18
+ - [Transactions](#transactions)
19
+ - [Update statements without `WHERE`](#update-statements-without-where)
20
+ - [Alter table](#alter-table)
16
21
  - [Installation](#installation)
17
22
  - [Usage](#usage)
18
23
  - [Contributing](#contributing)
@@ -29,12 +34,12 @@ Beyond migrations, I'm unsure how useful this gem is. I haven't yet tested what
29
34
  Features:
30
35
 
31
36
  - Connecting
32
- - Migrating
33
- - Table creation, with automatic removal of defaults from statements (since BigQuery doesn't support it)
37
+ - Migrating (see quirks)
38
+ - Table creation (see quirks)
34
39
  - Inserting rows
35
- - Updating rows, with automatic addition of `where 1 = 1` to statements (since BigQuery requires a `where` clause)
40
+ - Updating rows (see quirks)
36
41
  - Querying
37
- - Transactions (buffered since BigQuery only supports them when you execute the whole transaction at once)
42
+ - Transactions (see quirks)
38
43
  - Table partitioning
39
44
  - Ruby types:
40
45
  + String
@@ -46,6 +51,24 @@ Features:
46
51
  + BigDecimal
47
52
  - Selecting the BigQuery server location
48
53
 
54
+ ## Quirks
55
+
56
+ ### Creating tables with column defaults
57
+
58
+ BigQuery doesn't support defaults on columns. As a workaround, all defaults are automatically removed from statements (crudely).
59
+
60
+ ### Transactions
61
+
62
+ BigQuery doesn't support transactions where the statements are executed individually. It does support them if entire transaction SQL is sent all at once though. As a workaround, buffering of statements within a transaction has been implemented. However, the impact of this is that no results can be returned within a transaction.
63
+
64
+ ### Update statements without `WHERE`
65
+
66
+ BigQuery requires all `UPDATE` statement to have a `WHERE` clause. As a workaround, statements which lack one have `where 1 = 1` appended automatically (crudely).
67
+
68
+ ### Alter table
69
+
70
+ We've found that the `google-cloud-bigquery` gem seems to have a bug where an internal lack of result value results in a `NoMethodError` on nil for `fields` within `from_gapi_json`. [See issue #6](https://github.com/ZimbiX/sequel-bigquery/issues/6#issuecomment-968523731). As a workaround, all generated statements within `alter_table` are joined together with `;` and executed only at the end of the block. A `select 1` is also appended to try to ensure we have a result to avoid the aforementioned exception. A bonus of batching the queries is that the latency should be somewhat reduced.
71
+
49
72
  ## Installation
50
73
 
51
74
  Add it to the `Gemfile` of your project:
@@ -209,6 +209,13 @@ module Sequel
209
209
 
210
210
  sql
211
211
  end
212
+
213
+ # Batch the alter table queries and make sure something is returned to avoid an error related to the return value
214
+ def apply_alter_table(name, ops)
215
+ sqls = alter_table_sql_list(name, ops)
216
+ sqls_joined = (sqls + ['select 1']).join(";\n")
217
+ execute_ddl(sqls_joined)
218
+ end
212
219
  end
213
220
 
214
221
  class Dataset < Sequel::Dataset
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sequel
4
4
  module Bigquery
5
- VERSION = '0.4.2'
5
+ VERSION = '0.5.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel-bigquery
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brendan Weibrecht
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-08 00:00:00.000000000 Z
11
+ date: 2021-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: amazing_print