Python: Add a way to easily specify constant values for in new Value API.

This commit is contained in:
Mark Shannon
2019-07-31 11:23:07 +01:00
parent 6b2938a387
commit 5496fa41c8
6 changed files with 87 additions and 5 deletions

View File

@@ -0,0 +1,16 @@
| 1 | file://:0:0:0:0 | int 1 |
| 2 | file://:0:0:0:0 | int 2 |
| 3 | file://:0:0:0:0 | int 3 |
| 4 | file://:0:0:0:0 | int 4 |
| 5 | file://:0:0:0:0 | int 5 |
| 6 | file://:0:0:0:0 | int 6 |
| 7 | file://:0:0:0:0 | int 7 |
| 8 | file://:0:0:0:0 | int 8 |
| 9 | file://:0:0:0:0 | int 9 |
| 10 | file://:0:0:0:0 | int 10 |
| 1000 | file://:0:0:0:0 | int 1000 |
| 1004 | file://:0:0:0:0 | int 1004 |
| b'b' | file://:0:0:0:0 | 'b' |
| b'd' | file://:0:0:0:0 | 'd' |
| u'a' | file://:0:0:0:0 | 'a' |
| u'c' | file://:0:0:0:0 | 'c' |

View File

@@ -0,0 +1,20 @@
import python
from string txt, Value val
where
exists(string s |
txt = "u'" + s + "'" and val = Value::forUnicode(s)
or
txt = "b'" + s + "'" and val = Value::forBytes(s)
|
s = "a" or s = "b" or s = "c" or s = "d"
)
or
exists(int i |
txt = i.toString() and val = Value::forInt(i)
|
i in [1..10] or i in [1000..1010]
)
select txt, val

View File

@@ -0,0 +1,6 @@
u"a"
b"b"
u"c"
b"d"
1000
1004