raka 0.3.11 → 0.3.14

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/lib/raka/lang/psql/impl.rb +7 -6
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8c18ff3ef2a33821e333fec106d2f64ade89ca0f416d02c914ce5b5eb1601ba0
4
- data.tar.gz: ca858c3ea2807d209cceebe85ae1d4e987bd125597fd9575bb82d907785ed109
3
+ metadata.gz: 47d5f10053a5501bc7f06c7733d6060c48020d2479bb5fdbb1ed62780a767d27
4
+ data.tar.gz: 88dd5e16f853d0cb95dfdfe30d6999834661a79478006accb1377751761eaa43
5
5
  SHA512:
6
- metadata.gz: 9d8089d3f500a7f57789be879cd7f4f2fbadd2fd64ba0ca2957694289813587a5b603d7c0cb5fe8b5e84c442eccd7274f3203aef4f1e94f5830039e53cc7c3da
7
- data.tar.gz: 37625d41c5e2d09d47254d0be9497a95fcbc2b33810fb5ab942050763db35f4c2b3d1958c52a478b72eefe2c65e48ae619be52ec252e0365d58978bafaa2b0f9
6
+ metadata.gz: c72fb03df681dd169c32a6a882da89161a8842c3f3646c4fa63add8e256e51252541adeaf5dcc68b88baa17a7a3699eba5e4298920f57a5544556fcce0d27386
7
+ data.tar.gz: c10428d03695008c81dbcf209d04332fe01ba0771aab98b331ae087968625ec177e6dba52901c37cb9071811532475a07340a354e1f30245ce29d22c584fa64c
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.11
1
+ 0.3.14
@@ -17,9 +17,9 @@ end
17
17
  # postgresql protocol using psql, requires HOST, PORT, USER, DB
18
18
  class Psql
19
19
  # Sometimes we want to use the psql command with bash directly
20
- def sh_cmd(scope)
20
+ def sh_cmd(schema)
21
21
  c = @conn
22
- env_vars = "PGOPTIONS='-c search_path=#{scope ? scope + ',' : ''}public' "
22
+ env_vars = "PGOPTIONS='-c search_path=#{schema.empty? ? '' : schema + ','}public' "
23
23
  "PGPASSWORD=#{c.password} #{env_vars} psql -h #{c.host} -p #{c.port} -U #{c.user} -d #{c.db} -v ON_ERROR_STOP=1"
24
24
  end
25
25
 
@@ -35,10 +35,10 @@ class Psql
35
35
  raise 'argument conn required' if @conn.nil?
36
36
 
37
37
  if @create.to_s == 'table'
38
- 'DROP TABLE IF EXISTS :_name_;' \
38
+ 'DROP TABLE IF EXISTS :_schema_:_name_;' \
39
39
  'CREATE TABLE :_name_ AS (' + code + ');'
40
40
  elsif @create.to_s == 'mview'
41
- 'DROP MATERIALIZED VIEW IF EXISTS :_name_;' \
41
+ 'DROP MATERIALIZED VIEW IF EXISTS :_schema_:_name_;' \
42
42
  'CREATE MATERIALIZED VIEW :_name_ AS (' + code + ');'
43
43
  else
44
44
  code
@@ -47,10 +47,11 @@ class Psql
47
47
 
48
48
  def run_script(env, fname, task)
49
49
  param_str = (@params || {}).map { |k, v| "-v #{k}=\"#{v}\"" }.join(' ')
50
+ schema = task.rule_scopes.join('__')
50
51
 
51
52
  bash env, %(
52
- #{sh_cmd(task.rule_scopes.join('__'))} #{param_str} -v _name_=#{task.output_stem} \
53
- -f #{fname} | tee #{fname}.log
53
+ #{sh_cmd(schema)} #{param_str} -v _name_=#{task.output_stem} \
54
+ -v _schema_=#{schema.empty? ? '' : schema + '.'} -f #{fname} | tee #{fname}.log
54
55
  mv #{fname}.log #{task.name}
55
56
  )
56
57
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raka
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.11
4
+ version: 0.3.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - yarray
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-25 00:00:00.000000000 Z
11
+ date: 2022-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake