From 4ae9b156bf9007593dacbb2c7fc109a23ee9d610 Mon Sep 17 00:00:00 2001 From: Coding-Dev-Tools Date: Wed, 24 Jun 2026 08:11:31 -0400 Subject: [PATCH 1/3] improve: add AGENTS.md and harden flatten list typing --- AGENTS.md | 13 +++++++++++++ src/json2sql/converter.py | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 AGENTS.md diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..e2523e5 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,13 @@ +# json2sql — Agent Guide + +## Repo overview +This repo converts JSON to SQL. Primary implementation is under `src/json2sql/`. CLI entrypoints live in `cli.py` and `__main__.py`. + +## Commands +- Install/dev: `pip install -e .` +- Tests: `pytest` +- Lint/type checks (if configured): use tooling in `pyproject.toml` + +## Do not break +- Do not remove or weaken existing tests. +- Keep public CLI behavior stable unless an issue explicitly requests changing it. diff --git a/src/json2sql/converter.py b/src/json2sql/converter.py index f6b7cb8..fdb2ceb 100644 --- a/src/json2sql/converter.py +++ b/src/json2sql/converter.py @@ -163,7 +163,7 @@ def _infer_columns_flattened( inferred = sql_type_for(sub_value, self.dialect) if columns[flat_key] == "TEXT" and inferred != "TEXT": columns[flat_key] = inferred - elif isinstance(value, list) and value and isinstance(value[0], dict) and self.flatten: + elif isinstance(value, list) and value and self.flatten and all(isinstance(v, dict) for v in value): # Skip - goes to separate table pass else: From ee67736de591aab79fad70a220a54df245c5bc87 Mon Sep 17 00:00:00 2001 From: Coding-Dev-Tools Date: Wed, 24 Jun 2026 11:15:03 -0400 Subject: [PATCH 2/3] fix: harden list-of-dict type checks in flatten paths by reviewer-B --- src/json2sql/converter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/json2sql/converter.py b/src/json2sql/converter.py index fdb2ceb..deb0b0e 100644 --- a/src/json2sql/converter.py +++ b/src/json2sql/converter.py @@ -84,7 +84,7 @@ def _convert_objects(self, objects: list[dict], table_name: str) -> str: # Process nested arrays into child tables for obj in objects: for key, value in obj.items(): - if isinstance(value, list) and value and isinstance(value[0], dict): + if isinstance(value, list) and value and all(isinstance(v, dict) for v in value): self._flatten_nested(table_name, key, value, obj) else: columns = self._infer_columns(objects) @@ -216,5 +216,5 @@ def _process_flatten(self, objects: list, table_name: str) -> None: return for obj in objects: for key, value in obj.items(): - if isinstance(value, list) and value and isinstance(value[0], dict): + if isinstance(value, list) and value and all(isinstance(v, dict) for v in value): self._flatten_nested(table_name, key, value, obj) From cee08c86c94574d17d10f25cc4e2d95b64f1ac79 Mon Sep 17 00:00:00 2001 From: Coding-Dev-Tools Date: Thu, 25 Jun 2026 03:11:34 -0400 Subject: [PATCH 3/3] style: auto-fix ruff import sorting (I001) --- src/json2sql/cli.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/json2sql/cli.py b/src/json2sql/cli.py index 3cf4753..7d145e3 100644 --- a/src/json2sql/cli.py +++ b/src/json2sql/cli.py @@ -1,9 +1,9 @@ """CLI interface for json2sql using Typer.""" import sys +from pathlib import Path import typer -from pathlib import Path # Lazy imports — converter/dialects pulled on command execution # to reduce cold start from ~340ms to ~160ms. @@ -64,8 +64,6 @@ def convert( ), ): """Convert a JSON file to SQL INSERT statements.""" - from .converter import JSONToSQLConverter - from .dialects import Dialect # Validate dialect try: