Here are the examples of the python api sqlalchemy.func.jsonb_each taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
4 Examples
3
Source : test_query.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def test_scalar_table_valued(self, assets_transactions, connection):
stmt = select(
assets_transactions.c.id,
func.jsonb_each(
assets_transactions.c.contents, type_=JSONB
).scalar_table_valued("key"),
func.jsonb_each(
assets_transactions.c.contents, type_=JSONB
).scalar_table_valued("value"),
)
eq_(
connection.execute(stmt).all(),
[(1, "k1", "v1"), (2, "k2", "v2"), (3, "k3", "v3")],
)
def test_table_valued(self, assets_transactions, connection):
3
Source : test_query.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def test_table_valued(self, assets_transactions, connection):
jb = func.jsonb_each(assets_transactions.c.contents).table_valued(
"key", "value"
)
stmt = select(assets_transactions.c.id, jb.c.key, jb.c.value).join(
jb, true()
)
eq_(
connection.execute(stmt).all(),
[(1, "k1", "v1"), (2, "k2", "v2"), (3, "k3", "v3")],
)
@testing.fixture
0
Source : test_functions.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def test_scalar_table_valued(self):
assets_transactions = table(
"assets_transactions", column("id"), column("contents", JSON)
)
stmt = select(
assets_transactions.c.id,
func.jsonb_each(
assets_transactions.c.contents
).scalar_table_valued("key"),
func.jsonb_each(
assets_transactions.c.contents
).scalar_table_valued("value"),
)
self.assert_compile(
stmt,
"SELECT assets_transactions.id, "
"(jsonb_each(assets_transactions.contents)).key, "
"(jsonb_each(assets_transactions.contents)).value "
"FROM assets_transactions",
)
def test_table_valued_one(self):
0
Source : test_functions.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def test_table_valued_one(self):
assets_transactions = table(
"assets_transactions", column("id"), column("contents", JSON)
)
jb = func.jsonb_each(assets_transactions.c.contents).table_valued(
"key", "value"
)
stmt = select(assets_transactions.c.id, jb.c.key, jb.c.value).join(
jb, true()
)
self.assert_compile(
stmt,
"SELECT assets_transactions.id, anon_1.key, anon_1.value "
"FROM assets_transactions "
"JOIN jsonb_each(assets_transactions.contents) AS anon_1 ON true",
)
def test_table_valued_two(self):