edgedb-python icon indicating copy to clipboard operation
edgedb-python copied to clipboard

Element access in QB

Open vpetrovykh opened this issue 7 months ago • 1 comments

In EdgeQL we have several types that have elements access. The types str, bytes, json and any array have the indexing operator [x] and slicing [a:b]. These ideally should map directly to the same Python operators so that we could write:

q0 = default.User.filter(lambda u: u.name[0] == 'A')
q1 = default.User.filter(lambda u: u.name[0:2] == 'Zo')

Accessing tuple elements is done via .0, .1, etc. in EdgeQL. However, it might make sense to use [0], [1], etc. in Python QB.

type Foo {
  xy_coordinates: tuple<int64, int64>
}
q2 = default.Foo.filter(lambda f: f.xy_coordinates[0] = 1)

vpetrovykh avatar Jun 09 '25 19:06 vpetrovykh

@elprans says it's working already -- please validate

1st1 avatar Jun 16 '25 19:06 1st1