Hi there,
I've recently discovered PythonQL - Wow! I spent my spare time over the last 2 days to go through the intro and tutorial and have created a python script with all the examples in there. Everything works beautifully except for the two pattern matching examples.
The sample data is as follows
people = [ {'first':'John', 'last':'Doe', 'age':30,
'address' : {'city':'San Jose', 'zipcode':92122}},
{'first':'Daniela', 'last':'Kleene', 'age':40,
'address' : {'city':'San Jose', 'street':'Main', 'zipcode':92314}},
{'first':'Jerry', 'last':'Lee', 'age':50, 'occupation':'Engineer',
'address' : {'city':'San Jose', 'zipcode':93213}}
]
The first pattern matching example is as follows:
res = [ select (l, z)
match {
"last" : as l,
"age" : as a where a > 25,
"address" : {
"city" : "San Jose",
"zipcode" : as z
}
} as x in people ]
Now this first example works 100%.
The second pattern matching example is as follows
res = [ select x
match {
"last" : as _,
"first" : as _,
"age" : as a where a > 25,
"address" : {
"city" : as _,
"zipcode" : as _
}
} as x in people ]
]
This second pattern matching example has an error in that there appears to be an extra closing square bracket at the end.
Removing this bracket is obviously fixes the syntax error. This example is however supposed to return only the first record because it matches exactly - meaning it has all the same fields as the query but this example returns every record - according to the tutorial but it returns all the records (maybe this is the correct behaviour?).
If I now add an occupation field to the pattern it matches only the record that contains the occupation field. If I add a street field to the pattern nothing matches. If I now remove the occupation field but leave the street field in the pattern it matches the record that has the street field.
Am I missing something here? Or is the tutorial incorrect?
Hi there,
I've recently discovered PythonQL - Wow! I spent my spare time over the last 2 days to go through the intro and tutorial and have created a python script with all the examples in there. Everything works beautifully except for the two pattern matching examples.
The sample data is as follows
The first pattern matching example is as follows:
Now this first example works 100%.
The second pattern matching example is as follows
This second pattern matching example has an error in that there appears to be an extra closing square bracket at the end.
Removing this bracket is obviously fixes the syntax error. This example is however supposed to return only the first record because it matches exactly - meaning it has all the same fields as the query but this example returns every record - according to the tutorial but it returns all the records (maybe this is the correct behaviour?).
If I now add an
occupationfield to the pattern it matches only the record that contains the occupation field. If I add astreetfield to the pattern nothing matches. If I now remove theoccupationfield but leave thestreetfield in the pattern it matches the record that has thestreetfield.Am I missing something here? Or is the tutorial incorrect?