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 +4 -4
- data/lib/ar_query_matchers/queries/load_counter.rb +3 -15
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a03e79681fb7644c916a5f3c019a5e9484f8b7176e21b6c91beae9bd2d9eb520
|
4
|
+
data.tar.gz: 1a1d6f97aab26efa604ae32dd2d4b56164e4616ff87b2ffbfb84812e87e57a75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
-
#
|
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.
|
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-
|
11
|
+
date: 2021-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|