simple-sql 0.5.2 → 0.5.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 76825a68d4370b6f5e870a09f2013502706b0f35a83a911e5451fc147a9a1940
4
- data.tar.gz: 4093415861c077fbdf633dd1d347c6a6e2b2ed3da7df0c95dfaa078919d9b5d4
3
+ metadata.gz: 51df92f17c0c13dd73670dbc21467b255ca7e29cc96a306796103e16de24c0df
4
+ data.tar.gz: e9a153b9a8474fbee6a6b41e9923c35171e5c718776341a6f422422e306535bb
5
5
  SHA512:
6
- metadata.gz: 835f1c43a6d63d7647ba0d81c4dffabe39ef599f3623e47c3d62f2073e8f53dc88d54d387514efdb996aabdfebd5b0a599025eb3c0e4c3e2abe54685000323d9
7
- data.tar.gz: eda18e175ed172c11b3a8132fb956e66fbd06da57036ce65cb9361da9a1d66ca41edac4085fa4c048db69827025b5c49b8b7bde43d132f217e5defd0665f92e4
6
+ metadata.gz: 23ab1517045a92fd156e028d77a6b099effec4374e928866778f0fe2749eea4355707cb167e4bcd6e4c03d7747e7e71dbcec409a893a1bd47ff29477b05a5185
7
+ data.tar.gz: 0f939725994b15fe295040aaede96214b237423e1a6ec2b6557d656e2970415d7f3f1fe1cd3ad65e818b68c94ae953d3869feac4c347cd9d35dde4f04ee622d1
@@ -3,7 +3,7 @@
3
3
  # rubocop:disable Metrics/PerceivedComplexity
4
4
  # rubocop:disable Layout/AlignHash
5
5
 
6
- # private
6
+ # module to determine database configuration
7
7
  module Simple::SQL::Config
8
8
  extend self
9
9
 
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Simple
2
2
  module SQL
3
- VERSION = "0.5.2"
3
+ VERSION = "0.5.3"
4
4
  end
5
5
  end
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('git push origin master')
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 :push_to_rubygems do
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
- 'push_to_rubygems'
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:default'
107
+ task release: 'release:master'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple-sql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - radiospiel