kiroshi 0.3.0 → 0.3.1

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: 5748e560809cbfa28ea2b9d6ad06578ad1f4d0c67038bed6aca1a1978f27aa7c
4
- data.tar.gz: b15225c3e02cbb634ec4fec69c240cf7bb623e8d89d9fa216c0c5521e98f08a1
3
+ metadata.gz: cd64f4d8224df2417b3668f60fefdbaf11749f4eeb6bd0381d24d1635d6833c8
4
+ data.tar.gz: c67d36844e10bcc2121c53cf25ce3fad39e4327e5eb177441c13aed5357cd209
5
5
  SHA512:
6
- metadata.gz: e7ad5fe225a10041b672270a6f4407985c4be7b9761f9ae2ad5bfcebd45318c3caa03633dc066faf845e5b818fc36e8408e5991abf125d394b29b8af96ade5a3
7
- data.tar.gz: b7ba3b33bda40558ebc76e9a1cf4c9fd803fb4881e28eac16f38e64f5562ca6748bbdb206a12a416ab19376f619be26d52986339bedd9b929dc33b65fa68a36a
6
+ metadata.gz: 86c4086090a07690af87d41507d6e0b8ce64207c46f5301fc6152424cfbfa31894256bacfac8f1405df36915af7da11878b3292f55373e6f7ddc3a32fa021379
7
+ data.tar.gz: 2c49cf0d1828c65b97c829756adefa4ad4bb5328e1646ef631ef30d9f2005b50a1cce3a765a13af1dfaa0c9ff5dc949283be2a2c5bb9a73fa55bf93696cb88cc
data/README.md CHANGED
@@ -7,16 +7,16 @@
7
7
 
8
8
  ## Yard Documentation
9
9
 
10
- [https://www.rubydoc.info/gems/kiroshi/0.3.0](https://www.rubydoc.info/gems/kiroshi/0.3.0)
10
+ [https://www.rubydoc.info/gems/kiroshi/0.3.1](https://www.rubydoc.info/gems/kiroshi/0.3.1)
11
11
 
12
12
  Kiroshi has been designed to make filtering ActiveRecord queries easier
13
13
  by providing a flexible and reusable filtering system. It allows you to
14
14
  define filter sets that can be applied to any ActiveRecord scope,
15
15
  supporting both exact matches and partial matching using SQL LIKE operations.
16
16
 
17
- Current Release: [0.3.0](https://github.com/darthjee/kiroshi/tree/0.3.0)
17
+ Current Release: [0.3.1](https://github.com/darthjee/kiroshi/tree/0.3.1)
18
18
 
19
- [Next release](https://github.com/darthjee/kiroshi/compare/0.3.0...master)
19
+ [Next release](https://github.com/darthjee/kiroshi/compare/0.3.1...master)
20
20
 
21
21
  ## Installation
22
22
 
@@ -13,7 +13,7 @@ module Kiroshi
13
13
  # @example Applying LIKE match query
14
14
  # query = Kiroshi::FilterQuery::Like.new(filter_runner)
15
15
  # query.apply
16
- # # Generates: WHERE "table_name"."column" LIKE '%value%'
16
+ # # Generates: WHERE `table_name`.`column` LIKE '%value%'
17
17
  #
18
18
  # @since 0.1.1
19
19
  class Like < FilterQuery
@@ -28,7 +28,7 @@ module Kiroshi
28
28
  # @example Applying LIKE match
29
29
  # query = Like.new(filter_runner)
30
30
  # query.apply
31
- # # Generates: WHERE "documents"."name" LIKE '%ruby%'
31
+ # # Generates: WHERE `documents`.`name` LIKE '%ruby%'
32
32
  #
33
33
  # @since 0.1.1
34
34
  def apply
@@ -43,22 +43,18 @@ module Kiroshi
43
43
  # Builds the SQL query string for LIKE matching
44
44
  #
45
45
  # This method constructs the SQL fragment with proper table and column
46
- # qualification using double quotes to avoid conflicts with reserved words.
46
+ # qualification using backticks to avoid conflicts with reserved words.
47
47
  #
48
48
  # @return [String] the SQL query fragment for LIKE matching
49
49
  #
50
50
  # @example Generated SQL fragment
51
- # sql_query # => ' # Constructs the parameterized SQL query string for column matching
52
- #
53
- # @return [String] The SQL query string with placeholders
54
- # @example
55
51
  # sql_query
56
- # # Returns: '"table_name"."column" LIKE ?''
52
+ # # Returns: '`table_name`.`column` LIKE ?'
57
53
  #
58
54
  # @since 0.3.0
59
55
  def sql_query
60
56
  <<~SQL.squish
61
- "#{table_name}"."#{column}" LIKE ?
57
+ `#{table_name}`.`#{column}` LIKE ?
62
58
  SQL
63
59
  end
64
60
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kiroshi
4
- VERSION = '0.3.0'
4
+ VERSION = '0.3.1'
5
5
  end
@@ -17,7 +17,7 @@ RSpec.describe Kiroshi::FilterQuery::Like, type: :model do
17
17
 
18
18
  let(:expected_sql) do
19
19
  <<~SQL.squish
20
- SELECT "documents".* FROM "documents" WHERE ("documents"."name" LIKE '%test%')
20
+ SELECT "documents".* FROM "documents" WHERE (`documents`.`name` LIKE '%test%')
21
21
  SQL
22
22
  end
23
23
 
@@ -47,7 +47,7 @@ RSpec.describe Kiroshi::FilterQuery::Like, type: :model do
47
47
 
48
48
  let(:expected_sql) do
49
49
  <<~SQL.squish
50
- SELECT "documents".* FROM "documents" WHERE ("documents"."status" LIKE '%pub%')
50
+ SELECT "documents".* FROM "documents" WHERE (`documents`.`status` LIKE '%pub%')
51
51
  SQL
52
52
  end
53
53
 
@@ -78,7 +78,7 @@ RSpec.describe Kiroshi::FilterQuery::Like, type: :model do
78
78
 
79
79
  let(:expected_sql) do
80
80
  <<~SQL.squish
81
- SELECT "documents".* FROM "documents" WHERE ("documents"."version" LIKE '%1.2%')
81
+ SELECT "documents".* FROM "documents" WHERE (`documents`.`version` LIKE '%1.2%')
82
82
  SQL
83
83
  end
84
84
 
@@ -104,7 +104,7 @@ RSpec.describe Kiroshi::FilterQuery::Like, type: :model do
104
104
 
105
105
  let(:expected_sql) do
106
106
  <<~SQL.squish
107
- SELECT "documents".* FROM "documents" WHERE ("documents"."name" LIKE '%nonexistent%')
107
+ SELECT "documents".* FROM "documents" WHERE (`documents`.`name` LIKE '%nonexistent%')
108
108
  SQL
109
109
  end
110
110
 
@@ -218,7 +218,7 @@ RSpec.describe Kiroshi::FilterQuery::Like, type: :model do
218
218
 
219
219
  it 'generates SQL with tags table qualification' do
220
220
  result_sql = query.apply.to_sql
221
- expect(result_sql).to include('"tags"."name" LIKE')
221
+ expect(result_sql).to include('`tags`.`name` LIKE')
222
222
  end
223
223
 
224
224
  it 'generates SQL with correct LIKE pattern for tag name' do
@@ -245,7 +245,7 @@ RSpec.describe Kiroshi::FilterQuery::Like, type: :model do
245
245
 
246
246
  it 'generates SQL with documents table qualification' do
247
247
  result_sql = query.apply.to_sql
248
- expect(result_sql).to include('"documents"."name" LIKE')
248
+ expect(result_sql).to include('`documents`.`name` LIKE')
249
249
  end
250
250
 
251
251
  it 'generates SQL with correct LIKE pattern for document name' do
@@ -263,7 +263,7 @@ RSpec.describe Kiroshi::FilterQuery::Like, type: :model do
263
263
 
264
264
  it 'generates SQL with string table qualification' do
265
265
  result_sql = query.apply.to_sql
266
- expect(result_sql).to include('"tags"."name" LIKE')
266
+ expect(result_sql).to include('`tags`.`name` LIKE')
267
267
  end
268
268
  end
269
269
  end
@@ -278,7 +278,7 @@ RSpec.describe Kiroshi::FilterQuery::Like, type: :model do
278
278
 
279
279
  let(:expected_sql) do
280
280
  <<~SQL.squish
281
- SELECT "documents".* FROM "documents" WHERE ("documents"."full_name" LIKE '%John%')
281
+ SELECT "documents".* FROM "documents" WHERE (`documents`.`full_name` LIKE '%John%')
282
282
  SQL
283
283
  end
284
284
 
@@ -303,7 +303,7 @@ RSpec.describe Kiroshi::FilterQuery::Like, type: :model do
303
303
 
304
304
  let(:expected_sql) do
305
305
  <<~SQL.squish
306
- SELECT "documents".* FROM "documents" WHERE ("documents"."full_name" LIKE '%John%')
306
+ SELECT "documents".* FROM "documents" WHERE (`documents`.`full_name` LIKE '%John%')
307
307
  SQL
308
308
  end
309
309
 
@@ -39,7 +39,7 @@ RSpec.describe Kiroshi::FilterRunner, type: :model do
39
39
  end
40
40
 
41
41
  it 'generates correct SQL with table name prefix' do
42
- expected_sql = "SELECT \"documents\".* FROM \"documents\" WHERE (\"documents\".\"name\" LIKE '%test%')"
42
+ expected_sql = "SELECT \"documents\".* FROM \"documents\" WHERE (`documents`.`name` LIKE '%test%')"
43
43
  expect(runner.apply.to_sql).to eq(expected_sql)
44
44
  end
45
45
  end
@@ -126,7 +126,7 @@ RSpec.describe Kiroshi::FilterRunner, type: :model do
126
126
  end
127
127
 
128
128
  it 'generates correct LIKE SQL using the column name' do
129
- expected_sql = "SELECT \"documents\".* FROM \"documents\" WHERE (\"documents\".\"full_name\" LIKE '%John%')"
129
+ expected_sql = "SELECT \"documents\".* FROM \"documents\" WHERE (`documents`.`full_name` LIKE '%John%')"
130
130
  expect(runner.apply.to_sql).to eq(expected_sql)
131
131
  end
132
132
  end
@@ -52,7 +52,7 @@ RSpec.describe Kiroshi::Filters::ClassMethods, type: :model do
52
52
  it do
53
53
  expect { filters_class.filter_by :name, match: :like, table: :documents }
54
54
  .to change { filter_instance.apply(scope) }
55
- .from(scope).to(scope.where('"documents"."name" LIKE ?', '%test%'))
55
+ .from(scope).to(scope.where('`documents`.`name` LIKE ?', '%test%'))
56
56
  end
57
57
  end
58
58
 
@@ -73,7 +73,7 @@ RSpec.describe Kiroshi::Filters::ClassMethods, type: :model do
73
73
  it do
74
74
  expect { filters_class.filter_by :user_name, match: :like, column: :full_name }
75
75
  .to change { filter_instance.apply(scope) }
76
- .from(scope).to(scope.where('"documents"."full_name" LIKE ?', '%John%'))
76
+ .from(scope).to(scope.where('`documents`.`full_name` LIKE ?', '%John%'))
77
77
  end
78
78
  end
79
79
 
@@ -95,7 +95,7 @@ RSpec.describe Kiroshi::Filters::ClassMethods, type: :model do
95
95
  it do
96
96
  expect { filters_class.filter_by :tag_identifier, match: :like, table: :tags, column: :name }
97
97
  .to change { filter_instance.apply(scope) }
98
- .from(scope).to(scope.where('"tags"."name" LIKE ?', '%rub%'))
98
+ .from(scope).to(scope.where('`tags`.`name` LIKE ?', '%rub%'))
99
99
  end
100
100
  end
101
101
  end
@@ -279,7 +279,7 @@ RSpec.describe Kiroshi::Filters, type: :model do
279
279
 
280
280
  it 'generates SQL with table-qualified LIKE operation' do
281
281
  result = filter_instance.apply(scope)
282
- expect(result.to_sql).to include('"documents"."name" LIKE')
282
+ expect(result.to_sql).to include('`documents`.`name` LIKE')
283
283
  end
284
284
 
285
285
  it 'generates SQL with correct LIKE pattern' do
@@ -336,7 +336,7 @@ RSpec.describe Kiroshi::Filters, type: :model do
336
336
  end
337
337
 
338
338
  it 'generates SQL with LIKE operation on the specified column' do
339
- expect(filter_instance.apply(scope).to_sql).to include('"tags"."name" LIKE')
339
+ expect(filter_instance.apply(scope).to_sql).to include('`tags`.`name` LIKE')
340
340
  end
341
341
 
342
342
  it 'generates SQL with correct LIKE pattern' do
@@ -353,7 +353,7 @@ RSpec.describe Kiroshi::Filters, type: :model do
353
353
 
354
354
  it 'uses the column name in database queries' do
355
355
  result = filter_instance.apply(Document.all)
356
- expect(result.to_sql).to include('"documents"."name"')
356
+ expect(result.to_sql).to include('`documents`.`name`')
357
357
  end
358
358
 
359
359
  it 'does not use the filter key in SQL' do
@@ -451,7 +451,7 @@ RSpec.describe Kiroshi::Filters, type: :model do
451
451
  end
452
452
 
453
453
  it 'generates SQL that does not include documents.name' do
454
- expect(filter_instance.apply(scope).to_sql).not_to include('"documents"."name"')
454
+ expect(filter_instance.apply(scope).to_sql).not_to include('`documents`.`name`')
455
455
  end
456
456
 
457
457
  it 'generates SQL that includes the tag filter value' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kiroshi
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
  - Darthjee