-
Notifications
You must be signed in to change notification settings - Fork 3
Conversation
5951f73
to
df60de0
Compare
df60de0
to
1e14b99
Compare
if obj[field_name] == nil then | ||
return false | ||
end | ||
assert(rex ~= nil, 'we should not pass over :compile() ' .. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this comment or assert msg?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Propose one better or I’ll leave it as is.
graphql/accessor_general.lua
Outdated
@@ -696,6 +702,28 @@ local function validate_collections(collections, schemas) | |||
end | |||
end | |||
|
|||
--- XXX | |||
local function match_using_re(obj, pcre) | |||
if pcre == nil then return true end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this situation normal?
I suppose assert is more suitable here and this function is called only if necessary. But it is up to you...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pcre
is like filter
. You maybe confuse it with rex
— module variable.
@@ -741,9 +769,11 @@ local function process_tuple(state, tuple, opts) | |||
qstats.fetched_object_cnt, fetched_object_cnt_max)) | |||
assert(qcontext.deadline_clock > clock.monotonic64(), | |||
'query execution timeout exceeded, use `timeout_ms` to increase it') | |||
local collection_name = opts.collection_name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not like creating variables for one use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not like unpacking some opts, but don’t unpacking others. Debatable and non-important. Going to leave as is.
graphql/accessor_general.lua
Outdated
@@ -696,6 +702,28 @@ local function validate_collections(collections, schemas) | |||
end | |||
end | |||
|
|||
--- XXX | |||
local function match_using_re(obj, pcre) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer regexp
name over pcre
.
Pcre dis
- can be confusing for newcomers
- emphasizes implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I don’t know a developer that don’t know PCRE term.
- It holds a standard, not an implementation. Consider comment with link to the alternative lua PCRE implementation.
I’m tentative about your proposal. Maybe.
@@ -828,6 +859,8 @@ local function select_internal(self, collection_name, from, filter, args, extra) | |||
-- XXX: save type at parsing and check here | |||
--assert(args.offset == nil or type(args.offset) == 'number', | |||
-- 'args.offset must be a number of nil, got ' .. type(args.offset)) | |||
assert(args.pcre == nil or type(args.pcre) == 'table', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not like, that we loose structure of filters.
I suggest:
- Create single attribute
filter
filter
is a table which containsregexp
brute
(i do not insist on the naming, I insist on sense)index
I believe that this approach
- much more extensible
- would speed up future coding
- do not ban such names of fields like
pcre
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not in the scope of this issue.
graphql/accessor_general.lua
Outdated
local collection = self.collections[collection_name] | ||
local schema = self.schemas[collection.schema_name] | ||
for _, field in ipairs(schema.fields) do | ||
if field.name == field_name then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is about rested records?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
XXX mark above. Will file an issue re nested records and 1:1 connections (nested filters).
graphql/accessor_general.lua
Outdated
@@ -976,6 +1010,87 @@ local function init_qcontext(accessor, qcontext) | |||
settings.timeout_ms * 1000 * 1000 | |||
end | |||
|
|||
--- XXX | |||
local function get_primary_key_type(self, collection_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename pk_avro_type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Here all types are avro.
- I prefer to omit abbreviations where possible.
Debatable, non-important. Going to leave as is.
graphql/accessor_general.lua
Outdated
--- connection | ||
local function get_pcre_argument_type(self, collection_name) | ||
local collection = self.collections[collection_name] | ||
assert(collection ~= nil, 'cannot found collection ' .. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not write long messages to errors which should not occur. It just makes code-base huge and increases maintenance costs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cannot found collection %s
This error message is not long. You are about some other assert I guess. Propose your wording.
local pcre_field | ||
if rex ~= nil then | ||
local pcre_type = get_pcre_argument_type(self, collection_name) | ||
pcre_field = {name = 'pcre', type = pcre_type} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have wrote above. I do not lile pcre
name. Moreover in user-visible part.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m going to think about this bunch of problems in the scope of #39. Not now.
} | ||
]] | ||
|
||
utils.show_trace(function() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of this diff?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you read 215c1df comment?
1e14b99
to
ecf5b22
Compare
The criteria of correctness is that the following queries should produce the same results. ``` local gql = ... local query = [[ query foo_list($offset: foo_offset) { foo(offset: $offset) { ... } } ]] local variables = { offset = { bar = ..., baz = ..., } } print(yaml.encode(gql:compile(query):execute(variables))) ``` ``` local gql = ... local query = [[ query foo_list($bar: String, $baz: Long) { foo(offset: {bar: $bar, baz: $baz}) { ... } } ]] local variables = { bar = ..., baz = ..., } print(yaml.encode(gql:compile(query):execute(variables))) ```
Related to #73.
It is for make the function general and don't have fears of corner cases. It will loop in case of x = { ofType = x }, but it is anyway incorrect input.
ecf5b22
to
bc012ff
Compare
Related to #73.