recordx_sqlite 0.3.0 → 0.3.1

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: aac342f113f858c93a70cc2333e34bb84d5f91b7910d344241d914b0a3bd7e01
4
- data.tar.gz: 13da368af4262865562e33b44efbd45217a634a6f89db31648b0cf6f03b726b6
3
+ metadata.gz: 3db5139cd9c0e124459ca4a5f388ae556e6d7e07be90b5f6ed9c0c4e29e45005
4
+ data.tar.gz: 3d2966b40f159c7a07133ced693673540e0600f3a6da6cb5de8d0db33c6288cf
5
5
  SHA512:
6
- metadata.gz: 1c00a97da8f06749aac53a458685cccfee3a72c7ab629c6abdacdc5c07ce0cf77c3bda8b23c1e2cc6fbb9b2e3c95349d445510ac79f5c6c9e3bf929630b21cfc
7
- data.tar.gz: 59d0707c7f804dbefbc8ca564f4cc375c9dd2349870c2eddc5f4579a919e93f021215e45ecfdb28b8acd19921b7e4c8708c190bb26e4afd2cea7b9441e121c72
6
+ metadata.gz: 9509b33e7e585b1103c2fcd60971ac528d403a4c99cb20faab6d91a98b0a8f066ffec030af063e642dcd387841f9619e162d71a74b031b68349af54b711fa1e8
7
+ data.tar.gz: 20bc3cecc3f045b40db81d7e6b8f3008ec0b21a12418474466f1ed995bf0b37f0499815be62a47c0dd1c1fdf538122b1eb11ce9e1a5769ea44e382cb3b034eb3
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -14,7 +14,7 @@ class RecordxSqlite
14
14
 
15
15
  @debug = debug
16
16
  sqlite = dbfile =~ /^sqlite:\/\// ? DRbSQLite : SQLite3::Database
17
- @db = sqlite.new dbfile, debug: debug
17
+ @db = sqlite.new dbfile
18
18
 
19
19
  @db.results_as_hash = true
20
20
 
@@ -36,20 +36,42 @@ class RecordxSqlite
36
36
  @table = @db.tables.first
37
37
  @primary_key = @db.fields(@table).first
38
38
  else
39
+
39
40
  sql = "SELECT name FROM sqlite_master WHERE type='table';"
40
- a = @db.execute(sql).flat_map(&:to_a)
41
+ r = @db.execute(sql)
42
+ puts 'r: ' + r.inspect if @debug
43
+
44
+ a = r.map {|x| x['name']}
45
+ puts 'a: ' + a.inspect if @debug
46
+
41
47
  sys = a.grep /^sqlite_/
42
48
  @table = (a - sys).first
49
+ puts '@table: ' + @table.inspect if @debug
50
+
43
51
  @primary_key = @db.table_info(@table).map {|x| x['name'].to_sym }.first
52
+ puts '@primary_key: ' + @primary_key.inspect if @debug
53
+
44
54
  end
45
55
 
46
56
  end
47
57
 
48
- @sql = sql || 'select * from ' + @table.to_s
58
+ @sql = sql = 'select * from ' + @table.to_s
49
59
  @default_sql = @sql
50
60
  @pagesize = pagesize
51
61
  @a = nil
52
62
 
63
+ # create the fhe find_by methods for each fields
64
+ @db.table_info(@table).each do |cols|
65
+ #puts 'cols: ' + cols.inspect
66
+ define_singleton_method ('find_by_' + cols['name']).to_sym do |val|
67
+ find_by(cols['name'], val)
68
+ end
69
+
70
+ define_singleton_method ('find_all_by_' + cols['name']).to_sym do |val|
71
+ find_all_by(cols['name'], val)
72
+ end
73
+ end
74
+
53
75
  end
54
76
 
55
77
  # note: when using method all() you will need to call method refresh()
@@ -89,6 +111,20 @@ class RecordxSqlite
89
111
 
90
112
  end
91
113
 
114
+ def find_by(field, val)
115
+
116
+ query(@sql) unless @a
117
+ @a.find {|x| x.method(field).call == val}
118
+
119
+ end
120
+
121
+ def find_all_by(field, val)
122
+
123
+ query(@sql) unless @a
124
+ @a.select {|x| x.method(field).call == val}
125
+
126
+ end
127
+
92
128
  # returns the 1st n rows
93
129
  #
94
130
  def first(n=1)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recordx_sqlite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -11,31 +11,31 @@ cert_chain:
11
11
  - |
12
12
  -----BE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J06RhMHAlxw
31
- rzQdeqcSfS4PCOvFOBJw+mgZ+p0gH4t9bk7rbDfHtgj3ZmHSysoSsYZONKfG+zu7
32
- YlFcTmzyoV14wJNJG5yT2C3FCbAJ2NQSzZVSakHmAdMpF7dTZRLgROPBdM85ZPyp
33
- hMkoYX9R+HLnbvvW8gYroWr04bCkhFM36owm/C5pcE5v114Iz2fjsa1XU6sM7gXY
34
- jC+mD/9UKy2vxQwqFuahN/z8e82xvDpqg9z1VR4VdjBaDtmUSdu3oZGSXg73hh1c
35
- kccsQ7sAxN8HjTTcD7MMTYpZFDz95j0Q2C4BqH0dRtYCO7bU44KuuniAs+5s9tP9
36
- QWFC3bomTAgC+DL5m062pKLU
28
+ BgkqhkiG9w0BAQsFAAOCAYEAj65GR5UHe6vDPnTp38ivVIZskSlTCafWvO+oMI1L
29
+ UO9sLOjS3XDon+VSafMQaWtlf/f0CLHjjImuj/UUMqBU+XxGIQTjw01kCuErBIYH
30
+ KNPAv7P2Jm7ZOMNubvFTjPE6KvoslFbXEs0FPTf+MjiP/J1F6pHx4rcnxWoQ2qSq
31
+ uK7Zi8j3bRGDUGdW8c1btU8bUe3XsdfIwYRUvDm3E9fiHThH4Ta3uPLfeN6TCAje
32
+ qz2w2H+8jTC9zGdKh31dK9GUKneJiJ6EW8G27E9QWlZ0jezMLrjqzekSPGYREJBT
33
+ 45cJ79L4CUPnD+9WR75jGp2G3em8e/4nUlh29GvXOHi5SzpjuqEgLRRHLMG19mrg
34
+ Uy13/a2YkENgSlY9Q9bZW7jpb1CwVscJ4n+HLVb0fj8HKwsceJzeYf9JXHzJ2ykt
35
+ 14GYRdzYfQotOw5CFtPk6K1OgKW7WoEyiUBKdJanTGfXkAOum4dHWdWD7mm0RXx/
36
+ VfP9/tWv/9cP4k9V2nUJNEmu
37
37
  -----END CERTIFICATE-----
38
- date: 2019-08-24 00:00:00.000000000 Z
38
+ date: 2021-02-27 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: sqlite3
@@ -123,7 +123,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  requirements: []
126
- rubygems_version: 3.0.1
126
+ rubyforge_project:
127
+ rubygems_version: 2.7.10
127
128
  signing_key:
128
129
  specification_version: 4
129
130
  summary: RecordX-SQLite is an object relational mapper primarily designed for updating
metadata.gz.sig CHANGED
Binary file