kbforge-sql 0.1.0__tar.gz → 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: kbforge-sql
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: SQL source connector for kbforge
5
5
  Author-email: Qing <qingye779@gmail.com>
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "kbforge-sql"
3
- version = "0.1.0"
3
+ version = "0.1.1"
4
4
  description = "SQL source connector for kbforge"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"
@@ -128,7 +128,13 @@ def problems_for(config: dict) -> list[str]:
128
128
  problems.append(
129
129
  f"config 'exclude' names column(s) the source also uses: {sorted(clash)}"
130
130
  )
131
- if owned := sorted(set(cfg.facets) & OKF_OWNED):
131
+ # `tags` is exempted: unlike every other OKF-owned key, the emitter does not
132
+ # drop it. `assemble` (kbforge.synthesize) reads `structured["tags"]` and
133
+ # ships it as the concept's own tags, normalized by `_source_tags` (a
134
+ # string becomes one tag). A `tags` facet reaches the rendered concept, so
135
+ # rejecting it here would be a false positive -- exactly the failure mode
136
+ # this check exists to prevent for every OTHER owned key.
137
+ if owned := sorted(set(cfg.facets) & (OKF_OWNED - {"tags"})):
132
138
  problems.append(
133
139
  f"config 'facets' must not use OKF-owned key(s) {owned}: the emitter "
134
140
  "drops them, so the facet would silently never appear"
@@ -105,6 +105,16 @@ def test_a_facet_named_like_an_okf_key_is_rejected():
105
105
  )
106
106
 
107
107
 
108
+ def test_a_tags_facet_is_allowed():
109
+ # `tags` is OKF-owned too, but unlike the other owned keys the emitter does
110
+ # not drop it: `assemble` reads `structured["tags"]` and ships it,
111
+ # normalized (kbforge.synthesize._source_tags). Rejecting it here would be
112
+ # a false positive -- a deployment exposing a `tags` column worked before
113
+ # `tags` joined OKF_OWNED and must keep working.
114
+ problems = problems_for(_cfg(facets=["tags"]))
115
+ assert not any("facets" in p for p in problems)
116
+
117
+
108
118
  def test_group_children_must_not_include_id_columns():
109
119
  problems = problems_for(_cfg(group={"children": ["product_id", "x"]}))
110
120
  assert (
@@ -42,6 +42,35 @@ def test_a_flat_source_yields_one_document_per_row(tmp_path, monkeypatch):
42
42
  assert_fetch_contract(list(docs.values()), complete=True)
43
43
 
44
44
 
45
+ def test_a_tags_facet_ships_as_the_concept_top_level_tags(tmp_path, monkeypatch):
46
+ """Important 1 (#40 review): `tags` is OKF-owned but not dropped -- unlike
47
+ every other owned key, `assemble` (kbforge.synthesize) reads
48
+ `structured["tags"]` and ships it, normalized. A single string column
49
+ value becomes the single tag `["MOTIX"]`, not a split-on-comma list."""
50
+ import yaml
51
+
52
+ from kbforge.models import ChangeSet
53
+ from kbforge.synthesize import StubSynthesizer, concept_path
54
+
55
+ make_db(tmp_path, monkeypatch)
56
+ cfg = flat_cfg(
57
+ query=(
58
+ "SELECT product_id, product_name, family AS tags, status, "
59
+ "description, last_refreshed FROM product"
60
+ ),
61
+ facets=["tags", "status"],
62
+ )
63
+ _, docs = _docs(cfg)
64
+ doc = docs["products:IMC300"]
65
+ assert doc.structured["tags"] == "MOTIX" # a SQL string, not a list
66
+
67
+ proposal = StubSynthesizer().synthesize([doc], ChangeSet(added=[doc.doc_id]))
68
+ rendered = proposal.files[concept_path(doc.doc_id)]
69
+ front = yaml.safe_load(rendered.split("---\n")[1])
70
+ assert front["tags"] == ["MOTIX"] # one string is one tag, not split on ","
71
+ assert "tags" not in {**proposal.concepts[concept_path(doc.doc_id)].facets}
72
+
73
+
45
74
  def test_a_null_text_column_leaves_no_lead(tmp_path, monkeypatch):
46
75
  make_db(tmp_path, monkeypatch)
47
76
  _, docs = _docs(flat_cfg())
File without changes
File without changes