arql 0.4.1 → 0.4.3

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: dfa69341937ac1de34d54c8d3506759fd4979d59cc4d52333726cd8ba04fb346
4
- data.tar.gz: 4e65c0ea33d4c45c52e166839fdd777280d62d8b0c7127f8cb75760c0cfd230d
3
+ metadata.gz: 27b435e716bd7f2f1a9a806508fd4542887ed3a21ba02355ec0c1a5476cd3c0e
4
+ data.tar.gz: 59b8a4267407fcafe2df3714e785fd971cde979cc533802b33b3709ea2bc893d
5
5
  SHA512:
6
- metadata.gz: 3c1ac9cbcf12be0ca4c48040a7f7e007b72f09932ef26ec4a4b40ac168a10ce04771a8587bfc25800b21166975204a986c6c2265269dfe2953bc90cf16608c7f
7
- data.tar.gz: efe8de33f0365fcf871c0a160ddabeb4064e216a63fee7b9918af715d60dfd099e1881a124f8277d95e8ccb5c79df43eadfd660fa75f09f8f41c37806ce2e2f2
6
+ metadata.gz: 5493f7b368308e4e041c10f6562744bdb6ea47841959430c94e937b032f5d5fb44fbfc0d4217a9bc71b913fccdf70b4e23bd39f826bf47ec322a54223e2c34ab
7
+ data.tar.gz: b73fd3af4bcfbefe0502f5e7d44ad1dfcea63d22e906199550d3a432a0858769445d3d3d5e155e854e244e761616fe15e390e054306b24206aaf72abe13e2760
data/.vscode/launch.json CHANGED
@@ -6,12 +6,15 @@
6
6
  "configurations": [
7
7
  {
8
8
  "type": "rdbg",
9
- "name": "Debug current file with rdbg",
9
+ "name": "Debug Arql",
10
10
  "request": "launch",
11
11
  "script": "exe/arql",
12
12
  "command": "bundle exec",
13
13
  "useTerminal": true,
14
- "args": ["-e", "lcldevb,demo247"],
14
+ "args": [
15
+ "-e",
16
+ "${input:env}"
17
+ ],
15
18
  "askParameters": false
16
19
  },
17
20
  {
@@ -19,5 +22,18 @@
19
22
  "name": "Attach with rdbg",
20
23
  "request": "attach"
21
24
  }
25
+ ],
26
+ "inputs": [
27
+ {
28
+ "id": "env",
29
+ "type": "command",
30
+ "command": "extension.commandvariable.pickStringRemember",
31
+ "args": {
32
+ "fileName": "${userHome}/.arql.d/init.yml",
33
+ "pattern": {
34
+ "regexp": "^([\\w\\.]+):.*"
35
+ }
36
+ }
37
+ }
22
38
  ]
23
39
  }
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- arql (0.4.1)
4
+ arql (0.4.3)
5
5
  activerecord (>= 6.1.5, < 7.1.0)
6
6
  activesupport (>= 6.1.5, < 7.1.0)
7
7
  caxlsx (~> 3.3.0)
@@ -17,6 +17,20 @@ module Arql
17
17
  }
18
18
  end.t
19
19
  end
20
+
21
+ define_singleton_method(:like) do |**args|
22
+ send(:ransack, "#{args.keys.first}_cont" => args.values.first).result
23
+ end
24
+
25
+ def self.method_missing(method_name, *args, &block)
26
+ if method_name.to_s =~ /^(.+)_like$/
27
+ attr_name = $1.to_sym
28
+ return super unless respond_to?(attr_name)
29
+ send(:like, $1 => args.first)
30
+ else
31
+ super
32
+ end
33
+ end
20
34
  end
21
35
 
22
36
  class Definition
@@ -157,7 +171,7 @@ module Arql
157
171
  def get_connection_options
158
172
  connect_conf = @options.slice(:adapter, :host, :username, :password,
159
173
  :database, :encoding, :pool, :port, :socket)
160
- connect_conf.merge(@ssh_proxy.database_host_port) if @ssh_proxy
174
+ connect_conf.merge!(@ssh_proxy.database_host_port) if @ssh_proxy
161
175
  connect_conf
162
176
  end
163
177
 
@@ -0,0 +1,27 @@
1
+ module Ransack
2
+ module Adapters
3
+ module ActiveRecord
4
+ module Base
5
+ def ransack(params = {}, options = {})
6
+ old_base_connection = ::ActiveRecord::Base.method(:connection)
7
+ connection_obj = connection
8
+ ::ActiveRecord::Base.define_singleton_method(:connection) { connection_obj }
9
+ Search.new(self, params, options)
10
+ ensure
11
+ ::ActiveRecord::Base.define_singleton_method(:connection, old_base_connection)
12
+ end
13
+ end
14
+ end
15
+ end
16
+
17
+ class Search
18
+ def result(opts = {})
19
+ old_base_connection = ::ActiveRecord::Base.method(:connection)
20
+ connection_obj = @context.klass.connection
21
+ ::ActiveRecord::Base.define_singleton_method(:connection) { connection_obj }
22
+ @context.evaluate(self, opts)
23
+ ensure
24
+ ::ActiveRecord::Base.define_singleton_method(:connection, old_base_connection)
25
+ end
26
+ end
27
+ end
data/lib/arql/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Arql
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.3"
3
3
  end
data/lib/arql.rb CHANGED
@@ -19,6 +19,7 @@ require 'kaminari/activerecord'
19
19
  require 'composite_primary_keys'
20
20
  require 'ransack'
21
21
 
22
+ require 'arql/ext/active_record/base'
22
23
  require 'arql/ext/active_record/relation'
23
24
  require 'arql/ext/active_record/result'
24
25
  require 'arql/ext/ransack/search'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Liu Xiang
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-04-19 00:00:00.000000000 Z
11
+ date: 2024-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mysql2
@@ -340,6 +340,7 @@ files:
340
340
  - lib/arql/concerns/table_data_definition.rb
341
341
  - lib/arql/definition.rb
342
342
  - lib/arql/ext.rb
343
+ - lib/arql/ext/active_record/base.rb
343
344
  - lib/arql/ext/active_record/connection_adapters/abstract_mysql_adapter.rb
344
345
  - lib/arql/ext/active_record/connection_adapters/postgresql/schema_statements.rb
345
346
  - lib/arql/ext/active_record/relation.rb