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.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/raka/lang/psql/impl.rb +7 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47d5f10053a5501bc7f06c7733d6060c48020d2479bb5fdbb1ed62780a767d27
|
4
|
+
data.tar.gz: 88dd5e16f853d0cb95dfdfe30d6999834661a79478006accb1377751761eaa43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c72fb03df681dd169c32a6a882da89161a8842c3f3646c4fa63add8e256e51252541adeaf5dcc68b88baa17a7a3699eba5e4298920f57a5544556fcce0d27386
|
7
|
+
data.tar.gz: c10428d03695008c81dbcf209d04332fe01ba0771aab98b331ae087968625ec177e6dba52901c37cb9071811532475a07340a354e1f30245ce29d22c584fa64c
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.14
|
data/lib/raka/lang/psql/impl.rb
CHANGED
@@ -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(
|
20
|
+
def sh_cmd(schema)
|
21
21
|
c = @conn
|
22
|
-
env_vars = "PGOPTIONS='-c search_path=#{
|
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(
|
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.
|
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-
|
11
|
+
date: 2022-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|