Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions db/records.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def list_records_from_table(
group=None,
return_record_summaries=False,
table_record_summary_templates=None,
related_columns=None,
):
"""
Get records from a table.
Expand All @@ -36,6 +37,8 @@ def list_records_from_table(
group: An array of group definition objects.
return_record_summaries: Whether to return self record summaries.
table_record_summary_templates: A dict of record summary templates, per table.
related_columns: Optional list of related column requests to fetch
aggregated values from related tables.
"""
result = db_conn.exec_msar_func(
conn,
Expand All @@ -48,6 +51,7 @@ def list_records_from_table(
_json_or_none(group),
return_record_summaries,
_json_or_none(table_record_summary_templates),
_json_or_none(related_columns),
).fetchone()[0]
return result

Expand Down Expand Up @@ -89,6 +93,7 @@ def search_records_from_table(
offset=0,
return_record_summaries=False,
table_record_summary_templates=None,
related_columns=None,
):
"""
Get records from a table, according to a search specification
Expand All @@ -101,6 +106,8 @@ def search_records_from_table(
limit: The maximum number of rows we'll return.
return_record_summaries: Whether to return self record summaries.
table_record_summary_templates: A dict of record summary templates, per table.
related_columns: Optional list of related column requests to fetch
aggregated values from related tables.

The search definition objects should have the form
{"attnum": <int>, "literal": <text>}
Expand All @@ -115,6 +122,7 @@ def search_records_from_table(
offset,
return_record_summaries,
_json_or_none(table_record_summary_templates),
_json_or_none(related_columns),
).fetchone()[0]
return result

Expand Down
20 changes: 13 additions & 7 deletions db/sql/00_msar_all_objects_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ INSERT INTO msar.all_mathesar_objects VALUES
('__msar', '__msar.rename_schema(text,text)', 'FUNCTION', NULL),
('__msar', '__msar.rename_table(text,text)', 'FUNCTION', NULL),
('__msar', '__msar.set_not_nulls(text,__msar.not_null_def[])', 'FUNCTION', NULL),
('__msar', '__msar.split_ctes(text)', 'FUNCTION', NULL),
('__msar', '__msar.update_pk_sequence_to_latest(text,text)', 'FUNCTION', NULL),
('mathesar_types', 'mathesar_types.cast_to__double_quote_char_double_quote_("char")', 'FUNCTION', NULL),
('mathesar_types', 'mathesar_types.cast_to__double_quote_char_double_quote_(bigint)', 'FUNCTION', NULL),
Expand Down Expand Up @@ -1220,12 +1221,18 @@ INSERT INTO msar.all_mathesar_objects VALUES
('msar', 'msar.uri_parts(text)', 'FUNCTION', NULL),
('msar', 'msar.uri_path(text)', 'FUNCTION', NULL),
('msar', 'msar.uri_query(text)', 'FUNCTION', NULL),
('msar', 'msar.uri_scheme(text)', 'FUNCTION', NULL);


--
-- Name: all_mathesar_objects all_mathesar_objects_obj_schema_obj_name_obj_kind_key; Type: CONSTRAINT; Schema: msar; Owner: -
--
('msar', 'msar.uri_scheme(text)', 'FUNCTION', NULL),
('msar', 'msar.build_related_column_id(jsonb,integer)', 'FUNCTION', NULL),
('msar', 'msar.path_hash(jsonb)', 'FUNCTION', NULL),
('msar', 'msar.related_alias(text)', 'FUNCTION', NULL),
('msar', 'msar.value_col_name(integer,text)', 'FUNCTION', NULL),
('msar', 'msar.build_related_column_query(oid,jsonb,integer,text,text)', 'FUNCTION', NULL),
('msar', 'msar.build_related_columns_aggregation_query(jsonb,text)', 'FUNCTION', NULL),
('msar', 'msar.build_related_columns_ctes(oid,jsonb,text)', 'FUNCTION', NULL),
('msar', 'msar.build_related_columns_join_expr(oid,text,jsonb)', 'FUNCTION', NULL),
('msar', 'msar.list_records_from_table(oid,integer,integer,jsonb,jsonb,jsonb,boolean,jsonb,jsonb)', 'FUNCTION', NULL),
('msar', 'msar.search_records_from_table(oid,jsonb,integer,integer,boolean,jsonb,jsonb)', 'FUNCTION', NULL),
('msar', 'msar.split_ctes(text)', 'FUNCTION', NULL);

ALTER TABLE ONLY msar.all_mathesar_objects
ADD CONSTRAINT all_mathesar_objects_obj_schema_obj_name_obj_kind_key UNIQUE (obj_schema, obj_name, obj_kind);
Expand All @@ -1234,4 +1241,3 @@ ALTER TABLE ONLY msar.all_mathesar_objects
--
-- PostgreSQL database dump complete
--

Loading
Loading