simple-sql 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/simple/sql/config.rb +1 -1
- data/lib/simple/sql/connection/reflection.rb +23 -5
- data/lib/simple/sql/version.rb +1 -1
- data/tasks/release.rake +22 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51df92f17c0c13dd73670dbc21467b255ca7e29cc96a306796103e16de24c0df
|
4
|
+
data.tar.gz: e9a153b9a8474fbee6a6b41e9923c35171e5c718776341a6f422422e306535bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23ab1517045a92fd156e028d77a6b099effec4374e928866778f0fe2749eea4355707cb167e4bcd6e4c03d7747e7e71dbcec409a893a1bd47ff29477b05a5185
|
7
|
+
data.tar.gz: 0f939725994b15fe295040aaede96214b237423e1a6ec2b6557d656e2970415d7f3f1fe1cd3ad65e818b68c94ae953d3869feac4c347cd9d35dde4f04ee622d1
|
data/lib/simple/sql/config.rb
CHANGED
@@ -1,4 +1,8 @@
|
|
1
1
|
class Simple::SQL::Connection
|
2
|
+
def reset_reflection
|
3
|
+
@reflection = nil
|
4
|
+
end
|
5
|
+
|
2
6
|
def reflection
|
3
7
|
@reflection ||= Reflection.new(self)
|
4
8
|
end
|
@@ -38,6 +42,18 @@ class Simple::SQL::Connection
|
|
38
42
|
column_info(table_name).keys
|
39
43
|
end
|
40
44
|
|
45
|
+
def column_info(table_name)
|
46
|
+
@column_info ||= {}
|
47
|
+
@column_info[table_name] ||= _column_info(table_name)
|
48
|
+
end
|
49
|
+
|
50
|
+
# returns a Hash of column_name => column_type. Names are available both as
|
51
|
+
# Symbol and as String.
|
52
|
+
def column_types(table_name)
|
53
|
+
@column_types ||= {}
|
54
|
+
@column_types[table_name] ||= _column_types(table_name)
|
55
|
+
end
|
56
|
+
|
41
57
|
def table_info(schema: "public")
|
42
58
|
recs = @connection.all <<~SQL, schema, into: Hash
|
43
59
|
SELECT table_schema || '.' || table_name AS name, *
|
@@ -47,11 +63,6 @@ class Simple::SQL::Connection
|
|
47
63
|
records_by_attr(recs, :name)
|
48
64
|
end
|
49
65
|
|
50
|
-
def column_info(table_name)
|
51
|
-
@column_info ||= {}
|
52
|
-
@column_info[table_name] ||= _column_info(table_name)
|
53
|
-
end
|
54
|
-
|
55
66
|
private
|
56
67
|
|
57
68
|
def _column_info(table_name)
|
@@ -67,6 +78,13 @@ class Simple::SQL::Connection
|
|
67
78
|
records_by_attr(recs, :column_name)
|
68
79
|
end
|
69
80
|
|
81
|
+
def _column_types(table_name)
|
82
|
+
column_info = column_info(table_name)
|
83
|
+
column_info.each_with_object({}) do |(column_name, rec), hsh|
|
84
|
+
hsh[column_name.to_sym] = hsh[column_name.to_s] = rec.data_type
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
70
88
|
def parse_table_name(table_name)
|
71
89
|
p1, p2 = table_name.split(".", 2)
|
72
90
|
if p2
|
data/lib/simple/sql/version.rb
CHANGED
data/tasks/release.rake
CHANGED
@@ -61,7 +61,7 @@ namespace :release do
|
|
61
61
|
|
62
62
|
desc "Push code and tags"
|
63
63
|
task :push do
|
64
|
-
sh(
|
64
|
+
sh("git push origin #{$TARGET_BRANCH}")
|
65
65
|
sh('git push --tags')
|
66
66
|
end
|
67
67
|
|
@@ -71,19 +71,37 @@ namespace :release do
|
|
71
71
|
end
|
72
72
|
|
73
73
|
desc "Push Gem to gemfury"
|
74
|
-
task :
|
74
|
+
task :publish do
|
75
75
|
Dir.chdir(GEM_ROOT) { sh("gem push #{Dir.glob('*.gem').first}") }
|
76
76
|
end
|
77
77
|
|
78
|
+
task :target_master do
|
79
|
+
$TARGET_BRANCH = 'master'
|
80
|
+
end
|
81
|
+
|
82
|
+
task :target_stable do
|
83
|
+
$TARGET_BRANCH = 'stable'
|
84
|
+
end
|
85
|
+
|
86
|
+
task :checkout do
|
87
|
+
sh "git status --untracked-files=no --porcelain > /dev/null || (echo '*** working dir not clean' && false)"
|
88
|
+
sh "git checkout #{$TARGET_BRANCH}"
|
89
|
+
sh "git pull"
|
90
|
+
end
|
91
|
+
|
78
92
|
task default: [
|
93
|
+
'checkout',
|
79
94
|
'version',
|
80
95
|
'clean',
|
81
96
|
'build',
|
82
97
|
'commit',
|
83
98
|
'push',
|
84
|
-
'
|
99
|
+
'publish'
|
85
100
|
]
|
101
|
+
|
102
|
+
task master: %w(target_master default)
|
103
|
+
task stable: %w(target_stable default)
|
86
104
|
end
|
87
105
|
|
88
106
|
desc "Clean, build, commit and push"
|
89
|
-
task release: 'release:
|
107
|
+
task release: 'release:master'
|