ar-query-matchers 0.5.2.pre.5 → 0.5.2.pre.6

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: 2aaeaac19a8660c885b5ac75c32077ab6b0f835c53aaefa1bb3d3b7bab701fd4
4
- data.tar.gz: 3746c66186e7d067fc82895a8d7bb90dc230eb7ddef7553ad2bb9631bd69d097
3
+ metadata.gz: a03e79681fb7644c916a5f3c019a5e9484f8b7176e21b6c91beae9bd2d9eb520
4
+ data.tar.gz: 1a1d6f97aab26efa604ae32dd2d4b56164e4616ff87b2ffbfb84812e87e57a75
5
5
  SHA512:
6
- metadata.gz: 7d43af021387d6a1ea871bf13d876a512e19cf98eb702f85f9ff0446970c8f6bfbf40356d1eb0c1417664fd8b47ab4e8aab115785f06f8f22f547ab284dfa809
7
- data.tar.gz: f8785fb4accfb4f7a2573ced84211769793cc72bb6784de3884665f39a63346ebcc83046e737e6fca3e56a9fd1dbafc563805800b49df32ee77951137c76f8aa
6
+ metadata.gz: 960fb79a70f3875f606d67364227ad6b0af6440b18fed4e885a8a44614d61f484ad7cdc33e6040b114b568d320edcc045a212a9db0c570577a039bb7a04b09c6
7
+ data.tar.gz: 379ef8320c724772bcf9fc38dda46a86fa8a24a8690a9547a13973065dcebef9fae17f77a636e059463f91afbba2aa341164ddadbe900e58fb625d3f1b64a5c4
@@ -15,24 +15,12 @@ module ArQueryMatchers
15
15
  end
16
16
 
17
17
  class LoadQueryFilter < Queries::QueryFilter
18
- # Matches named SQL operations like the following:
19
- # 'User Load'
20
- MODEL_LOAD_PATTERN = /\A(?<model_name>[\w:]+) (Load|Exists)\Z/.freeze
21
-
22
18
  # Matches unnamed SQL operations like the following:
23
- # "SELECT COUNT(*) FROM `users` ..."
24
- MODEL_SQL_PATTERN = /FROM [`"](?<table_name>[^`"]+)[`"]/.freeze
19
+ # "SELECT * FROM `users` ..."
20
+ MODEL_SQL_PATTERN = /SELECT (?:(?!SELECT).)* FROM [`"](?<table_name>[^`"]+)[`"]/.freeze
25
21
 
26
22
  def filter_map(_name, sql)
27
- # First check for a `SELECT * FROM` query that ActiveRecord has
28
- # helpfully named for us in the payload
29
- #
30
- # NOTE: This misses possible subqueries and prevents us from getting
31
- # to the below matcher
32
- # match = name.match(MODEL_LOAD_PATTERN)
33
- # return [ModelName.new(match[:model_name])] if match
34
-
35
- # Fall back to pattern-matching on the table name in a COUNT and looking
23
+ # Pattern-matching on the table name in a SELECT ... FROM and looking
36
24
  # up the table name from ActiveRecord's loaded descendants.
37
25
  selects_from_table = sql.scan(MODEL_SQL_PATTERN)
38
26
  selects_from_table.map { |(table_name)| TableName.new(table_name) } unless selects_from_table.empty?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ar-query-matchers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2.pre.5
4
+ version: 0.5.2.pre.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matan Zruya
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-25 00:00:00.000000000 Z
11
+ date: 2021-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord