From b3220972853e815b00ce8a0bd6dfa8b5fd75b713 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Sun, 4 Oct 2026 21:55:19 +0200 Subject: [PATCH] Declare instants, sequences and segments generic over every temporal type meta/type-scope.json declares temporal_instants, temporal_sequences and temporal_segments generic over Temporal *, as it declares temporal_start_instant and temporal_end_instant, so each keeps the signature of every temporal type its wrapper declares: instants, sequences and segments over the 20 temporal types. They take a const Temporal * and validate it for being present alone, so no signal of MEOS states their scope, and the scope their parameter type gives is tint. Witness: a catalog derived from MobilityDB master 8600f6905a gives temporal_instants the one signature instants(tint), and temporal_sequences and temporal_segments likewise one each, so a binding generated from the public accessors reaches instants, sequences and segments over tint alone. Measured over MobilityDB master 8600f6905a and the installed headers of a libmeos built from it: the three accessors keep 20 signatures each, the first argument ranging over the 20 temporal types; with the @csqlfn tags of the MobilityDB branch fix/array-accessors-call-the-public-api, no other function keeps a signature of instants, sequences or segments, and the derived catalog differs from master's in these eight functions alone. The suite passes, 25 tests skipped as on master, tests/test_typescope.py stating the three over the generated catalog. Why: the accessors behind instants, sequences and segments are generic, so their scope is stated where MEOS states none, as the file states every other generic accessor. --- meta/type-scope.json | 12 ++++++++++++ tests/test_typescope.py | 19 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/meta/type-scope.json b/meta/type-scope.json index 5aadef5..50f96d5 100644 --- a/meta/type-scope.json +++ b/meta/type-scope.json @@ -26,6 +26,18 @@ "types": "*", "note": "Generic over Temporal *: accessor on any temporal type." }, + "temporal_instants": { + "types": "*", + "note": "Generic over Temporal *: the distinct instants of any temporal type, the call behind instants." + }, + "temporal_sequences": { + "types": "*", + "note": "Generic over Temporal *: the sequences of any temporal type, the call behind sequences." + }, + "temporal_segments": { + "types": "*", + "note": "Generic over Temporal *: the segments of any temporal type, the call behind segments." + }, "temporal_start_instant": { "types": "*", "note": "Generic over Temporal *: accessor on any temporal type." diff --git a/tests/test_typescope.py b/tests/test_typescope.py index cb6282c..7f4511f 100644 --- a/tests/test_typescope.py +++ b/tests/test_typescope.py @@ -162,5 +162,24 @@ def test_a_declared_scope_is_taken_as_stated(self): self.assertEqual(kept, FROM_BASE_TSTZSET) +IDL = Path(__file__).resolve().parent.parent / 'output' / 'meos-idl.json' + + +class DeclaredScopeContractTests(unittest.TestCase): + """Over the generated catalog, as #CodecContractTests of tests/test_codecs.py reads it: a + function declared generic serves every overload its wrapper declares.""" + + def setUp(self): + if not IDL.exists(): + self.skipTest(f"{IDL} not generated; run `python run.py` first") + self.fns = {f['name']: f for f in json.loads(IDL.read_text())['functions']} + + def test_the_array_accessors_serve_every_temporal_type(self): + for name in ('temporal_instants', 'temporal_sequences', 'temporal_segments'): + first = {s['args'][0] for s in self.fns[name].get('sqlSignatures') or ()} + self.assertTrue({'tint', 'tfloat', 'ttext', 'tgeompoint', 'tgeogpoint'} <= first, + f'{name} serves {sorted(first)}') + + if __name__ == '__main__': unittest.main()