matrx-orm 1.2.2__tar.gz → 1.2.4__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.
Files changed (96) hide show
  1. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/PKG-INFO +1 -1
  2. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/pyproject.toml +1 -1
  3. matrx_orm-1.2.4/release.sh +104 -0
  4. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/core/config.py +3 -1
  5. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/schema_builder/individual_managers/columns.py +18 -0
  6. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/schema_builder/individual_managers/common.py +3 -3
  7. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/schema_builder/individual_managers/schema.py +22 -2
  8. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/schema_builder/individual_managers/tables.py +7 -1
  9. matrx_orm-1.2.4/test_model_cls_refactor.py +91 -0
  10. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/.env.example +0 -0
  11. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/.github/workflows/publish.yml +0 -0
  12. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/.gitignore +0 -0
  13. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/.python-version +0 -0
  14. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/README.md +0 -0
  15. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/REFACTORING_SUMMARY.md +0 -0
  16. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/RESERVED_NAMES.md +0 -0
  17. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/main.py +0 -0
  18. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/__init__.py +0 -0
  19. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/adapters/__init__.py +0 -0
  20. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/adapters/base_adapter.py +0 -0
  21. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/adapters/postgresql.py +0 -0
  22. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/client/__init__.py +0 -0
  23. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/client/postgres_connection.py +0 -0
  24. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/constants.py +0 -0
  25. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/core/__init__.py +0 -0
  26. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/core/async_db_manager.py +0 -0
  27. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/core/base.py +0 -0
  28. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/core/expressions.py +0 -0
  29. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/core/extended.py +0 -0
  30. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/core/fields.py +0 -0
  31. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/core/registry.py +0 -0
  32. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/core/relations.py +0 -0
  33. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/error_handling.py +0 -0
  34. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/exceptions.py +0 -0
  35. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/extended/__init__.py +0 -0
  36. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/extended/app_error_handler.py +0 -0
  37. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/middleware/__init__.py +0 -0
  38. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/middleware/base.py +0 -0
  39. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/operations/__init__.py +0 -0
  40. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/operations/create.py +0 -0
  41. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/operations/delete.py +0 -0
  42. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/operations/read.py +0 -0
  43. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/operations/update.py +0 -0
  44. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/python_sql/__init__.py +0 -0
  45. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/python_sql/db_objects.py +0 -0
  46. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/python_sql/table_detailed_relationships.py +0 -0
  47. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/python_sql/table_typescript_relationship.py +0 -0
  48. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/query/__init__.py +0 -0
  49. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/query/builder.py +0 -0
  50. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/query/executor.py +0 -0
  51. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/schema_builder/__init__.py +0 -0
  52. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/schema_builder/generator.py +0 -0
  53. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/schema_builder/helpers/__init__.py +0 -0
  54. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/schema_builder/helpers/configs.py +0 -0
  55. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/schema_builder/helpers/git_checker.py +0 -0
  56. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/schema_builder/helpers/manager_dto_creator.py +0 -0
  57. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/schema_builder/helpers/manager_helpers.py +0 -0
  58. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/schema_builder/helpers/manual_overrides.py +0 -0
  59. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/schema_builder/individual_managers/__init__.py +0 -0
  60. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/schema_builder/individual_managers/relationships.py +0 -0
  61. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/schema_builder/individual_managers/views.py +0 -0
  62. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/schema_builder/parts_generators/__init__.py +0 -0
  63. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/schema_builder/parts_generators/entity_field_override_generator.py +0 -0
  64. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/schema_builder/parts_generators/entity_main_hook_generator.py +0 -0
  65. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/schema_builder/parts_generators/entity_override_generator.py +0 -0
  66. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/schema_builder/schema_manager.py +0 -0
  67. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/sql_executor/__init__.py +0 -0
  68. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/sql_executor/executor.py +0 -0
  69. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/sql_executor/queries.py +0 -0
  70. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/sql_executor/registry.py +0 -0
  71. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/sql_executor/types.py +0 -0
  72. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/sql_executor/utils.py +0 -0
  73. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/state.py +0 -0
  74. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/structure.md +0 -0
  75. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/utils/__init__.py +0 -0
  76. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/utils/sql_utils.py +0 -0
  77. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/src/matrx_orm/utils/type_converters.py +0 -0
  78. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/tests/__init__.py +0 -0
  79. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/tests/database_project_config.py +0 -0
  80. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/tests/generation_test.py +0 -0
  81. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/tests/load_env_for_test.py +0 -0
  82. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/tests/orm_tests/__init__.py +0 -0
  83. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/tests/orm_tests/additional_tests.py +0 -0
  84. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/tests/orm_tests/broker_manager_test.py +0 -0
  85. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/tests/orm_tests/broker_manager_with_base.py +0 -0
  86. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/tests/orm_tests/cache_management.py +0 -0
  87. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/tests/orm_tests/core_model_tests.py +0 -0
  88. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/tests/orm_tests/demo.py +0 -0
  89. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/tests/orm_tests/junk.py +0 -0
  90. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/tests/orm_tests/manager_test.py +0 -0
  91. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/tests/orm_tests/recipe_test.py +0 -0
  92. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/tests/orm_tests/relationship_trials.py +0 -0
  93. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/tests/orm_tests/sample_test.py +0 -0
  94. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/tests/orm_tests/test_error_handling.py +0 -0
  95. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/tests/query_executor.py +0 -0
  96. {matrx_orm-1.2.2 → matrx_orm-1.2.4}/uv.lock +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: matrx-orm
3
- Version: 1.2.2
3
+ Version: 1.2.4
4
4
  Summary: Add your description here
5
5
  Author-email: jatin.b.rx3@gmail.com
6
6
  Requires-Python: >=3.10
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "matrx-orm"
3
- version = "1.2.2"
3
+ version = "1.2.4"
4
4
  description = "Add your description here"
5
5
  readme = "README.md"
6
6
  authors = [
@@ -0,0 +1,104 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ PYPROJECT="pyproject.toml"
5
+ REMOTE="origin"
6
+ BRANCH="main"
7
+
8
+ # ── Colors ──────────────────────────────────────────────────────────────────
9
+ RED='\033[0;31m'
10
+ GREEN='\033[0;32m'
11
+ YELLOW='\033[1;33m'
12
+ CYAN='\033[0;36m'
13
+ NC='\033[0m'
14
+
15
+ info() { echo -e "${CYAN}[INFO]${NC} $*"; }
16
+ ok() { echo -e "${GREEN}[OK]${NC} $*"; }
17
+ warn() { echo -e "${YELLOW}[WARN]${NC} $*"; }
18
+ fail() { echo -e "${RED}[FAIL]${NC} $*"; exit 1; }
19
+
20
+ # ── Pre-flight checks ──────────────────────────────────────────────────────
21
+
22
+ # Must be in the repo root (where pyproject.toml lives)
23
+ [[ -f "$PYPROJECT" ]] || fail "$PYPROJECT not found. Run this from the repo root."
24
+
25
+ # Must be on the main branch
26
+ CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
27
+ [[ "$CURRENT_BRANCH" == "$BRANCH" ]] || fail "Not on $BRANCH branch (on $CURRENT_BRANCH). Switch first."
28
+
29
+ # Must have a clean working tree (user should have already committed)
30
+ if [[ -n "$(git diff --cached --name-only)" ]]; then
31
+ fail "You have staged but uncommitted changes. Commit first, then run this script."
32
+ fi
33
+
34
+ if [[ -n "$(git diff --name-only)" ]]; then
35
+ warn "You have unstaged changes in tracked files. They will NOT be included."
36
+ echo -e " Untracked files are always ignored.\n"
37
+ fi
38
+
39
+ # Must have at least one commit ahead of remote (the user's commit)
40
+ LOCAL_HEAD=$(git rev-parse HEAD)
41
+ REMOTE_HEAD=$(git rev-parse "$REMOTE/$BRANCH" 2>/dev/null || echo "none")
42
+ if [[ "$LOCAL_HEAD" == "$REMOTE_HEAD" ]]; then
43
+ fail "No new commits to release. Commit your changes first, then run this script."
44
+ fi
45
+
46
+ # ── Read & bump version ────────────────────────────────────────────────────
47
+
48
+ CURRENT_VERSION=$(grep '^version = ' "$PYPROJECT" | sed 's/version = "\(.*\)"/\1/')
49
+ [[ -n "$CURRENT_VERSION" ]] || fail "Could not read version from $PYPROJECT"
50
+
51
+ IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
52
+ NEW_PATCH=$((PATCH + 1))
53
+ NEW_VERSION="${MAJOR}.${MINOR}.${NEW_PATCH}"
54
+ NEW_TAG="v${NEW_VERSION}"
55
+
56
+ info "Current version: $CURRENT_VERSION"
57
+ info "New version: $NEW_VERSION"
58
+ info "Tag: $NEW_TAG"
59
+
60
+ # Check tag doesn't already exist
61
+ if git rev-parse "$NEW_TAG" &>/dev/null; then
62
+ fail "Tag $NEW_TAG already exists. Manually resolve the version."
63
+ fi
64
+
65
+ echo ""
66
+
67
+ # ── Update pyproject.toml and amend the commit ─────────────────────────────
68
+
69
+ info "Updating $PYPROJECT to version $NEW_VERSION..."
70
+ sed -i "s/^version = \"$CURRENT_VERSION\"/version = \"$NEW_VERSION\"/" "$PYPROJECT"
71
+ ok "Version updated in $PYPROJECT"
72
+
73
+ info "Amending last commit to include version bump..."
74
+ git add "$PYPROJECT"
75
+ git commit --amend --no-edit --quiet
76
+ ok "Commit amended"
77
+
78
+ # ── Push commit ─────────────────────────────────────────────────────────────
79
+
80
+ info "Pushing to $REMOTE/$BRANCH..."
81
+ git push "$REMOTE" "$BRANCH"
82
+ ok "Pushed to $REMOTE/$BRANCH"
83
+
84
+ # ── Tag and push tag ───────────────────────────────────────────────────────
85
+
86
+ info "Creating tag $NEW_TAG..."
87
+ git tag "$NEW_TAG"
88
+ ok "Tag created"
89
+
90
+ info "Pushing tag $NEW_TAG..."
91
+ git push "$REMOTE" "$NEW_TAG"
92
+ ok "Tag pushed"
93
+
94
+ # ── Done ────────────────────────────────────────────────────────────────────
95
+
96
+ echo ""
97
+ echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
98
+ echo -e "${GREEN} Released matrx-orm $NEW_VERSION${NC}"
99
+ echo -e "${GREEN} GitHub Actions will now build and publish to PyPI.${NC}"
100
+ echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
101
+ echo ""
102
+ echo -e " Monitor: ${CYAN}https://github.com/armanisadeghi/matrx-orm/actions${NC}"
103
+ echo -e " Update: ${CYAN}uv add matrx-orm@${NEW_VERSION}${NC}"
104
+ echo ""
@@ -170,9 +170,11 @@ def get_code_config(db_project):
170
170
  "temp_path": "models.py",
171
171
  "root": ADMIN_PYTHON_ROOT,
172
172
  "file_location": f"# File: database/{usable_name}/models.py",
173
+ # Note: import_lines are dynamically replaced by generate_models() in schema.py
174
+ # based on the actual field types used. This is a fallback default only.
173
175
  "import_lines": [
174
176
  "import database_registry",
175
- "from matrx_orm import CharField, EnumField, DateField, TextField, IntegerField, FloatField, BooleanField, DateTimeField, UUIDField, JSONField, DecimalField, BigIntegerField, SmallIntegerField, JSONBField, UUIDArrayField, JSONBArrayField, IPAddressField, ForeignKey, Model, model_registry, BaseDTO, BaseManager",
177
+ "from matrx_orm import Model, model_registry, BaseDTO, BaseManager",
176
178
  "from enum import Enum",
177
179
  "from dataclasses import dataclass"
178
180
  ],
@@ -791,6 +791,14 @@ class Column:
791
791
  "blank": value.split("'")[1].strip(), # Extract timestamp with timezone
792
792
  "generator": "formatTimestamptz()",
793
793
  },
794
+ "::time without time zone": lambda value: {
795
+ "blank": value.split("'")[1].strip(), # Extract time value
796
+ "generator": "formatTime()",
797
+ },
798
+ "::time with time zone": lambda value: {
799
+ "blank": value.split("'")[1].strip(), # Extract time with timezone value
800
+ "generator": "formatTime()",
801
+ },
794
802
  "::uuid": lambda uuid_value: {
795
803
  "blank": uuid_value.split("'")[1].strip() if "'" in uuid_value else uuid_value.strip(),
796
804
  "generator": "",
@@ -884,6 +892,10 @@ class Column:
884
892
  elif value.startswith("ARRAY[]::") and value.endswith("[]"):
885
893
  return {"blank": "[]", "generator": ""}
886
894
 
895
+ # Handle non-empty ARRAY[...] syntax: ARRAY['react'::text, 'lucide-react'::text, ...]
896
+ elif value.startswith("ARRAY["):
897
+ return {"blank": "[]", "generator": ""}
898
+
887
899
  # Handle simple numeric defaults (no quotes, no casting)
888
900
  # This includes integers, decimals, negative numbers, scientific notation
889
901
  elif value.isdigit() or (value.startswith("-") and value[1:].replace(".", "", 1).isdigit()):
@@ -942,6 +954,12 @@ class Column:
942
954
  vcprint(data=value, color="red")
943
955
  return callable_outcomes["::timestamp with time zone"](value)
944
956
 
957
+ if value.endswith("::time without time zone"):
958
+ return callable_outcomes["::time without time zone"](value)
959
+
960
+ if value.endswith("::time with time zone"):
961
+ return callable_outcomes["::time with time zone"](value)
962
+
945
963
  if value.endswith("::uuid"):
946
964
  uuid_value = value.split("::")[0].strip("'") # Extract UUID without validation
947
965
  return callable_outcomes["::uuid"](uuid_value)
@@ -10,7 +10,7 @@ schema_builder_save_direct = True
10
10
 
11
11
 
12
12
  DEBUG_SETTINGS = {
13
- "tables": ["wc_impairment_definition"],
14
- "columns": ["name"],
15
- "base_type": [""],
13
+ "tables": [],
14
+ "columns": [],
15
+ "base_type": [],
16
16
  }
@@ -652,10 +652,19 @@ class Schema:
652
652
  remaining_tables.remove(table_name)
653
653
 
654
654
  py_structure = [self.get_string_user_model()]
655
+ all_field_types = {"UUIDField", "CharField", "Model"}
656
+
655
657
  for table_name in sorted_tables:
656
658
  table = self.tables[table_name]
657
659
  py_table_entry = table.to_python_model()
658
660
  py_structure.append(py_table_entry)
661
+ all_field_types.update(table.unique_field_types)
662
+
663
+ has_enums = any(
664
+ column.has_enum_labels
665
+ for table in self.tables.values()
666
+ for column in table.columns
667
+ )
659
668
 
660
669
  py_manager_structure = []
661
670
  py_auto_config_structure = []
@@ -690,8 +699,19 @@ class Schema:
690
699
  print("python_models", get_code_config(self.database_project)["python_models"])
691
700
  print("-----------------------------\n")
692
701
 
693
- self.code_handler.generate_and_save_code_from_object(get_code_config(self.database_project)["python_models"],
694
- main_code, additional_code)
702
+ models_config = get_code_config(self.database_project)["python_models"]
703
+ sorted_field_types = sorted(all_field_types)
704
+ field_imports = ", ".join(sorted_field_types)
705
+ dynamic_import_lines = [
706
+ "import database_registry",
707
+ f"from matrx_orm import {field_imports}, model_registry, BaseDTO, BaseManager",
708
+ ]
709
+ if has_enums:
710
+ dynamic_import_lines.append("from enum import Enum")
711
+ dynamic_import_lines.append("from dataclasses import dataclass")
712
+ models_config["import_lines"] = dynamic_import_lines
713
+
714
+ self.code_handler.generate_and_save_code_from_object(models_config, main_code, additional_code)
695
715
 
696
716
 
697
717
  py_auto_config_code = "\n".join(py_auto_config_structure)
@@ -1021,7 +1021,13 @@ class Table:
1021
1021
  for column in self.columns:
1022
1022
  py_field = column.to_python_model_field()
1023
1023
  py_fields.append(py_field)
1024
- self.unique_field_types.add(column.python_field_type)
1024
+
1025
+ if column.foreign_key_reference:
1026
+ self.unique_field_types.add("ForeignKey")
1027
+ elif column.has_enum_labels:
1028
+ self.unique_field_types.add("EnumField")
1029
+ else:
1030
+ self.unique_field_types.add(column.python_field_type)
1025
1031
 
1026
1032
  if column.has_enum_labels:
1027
1033
  py_enum_entry = column.set_python_enum_entry()
@@ -0,0 +1,91 @@
1
+ """
2
+ Test script to verify the model_cls refactoring works correctly.
3
+
4
+ This test creates a simple model with a field named 'model' to ensure
5
+ there are no conflicts with the internal model_cls parameter.
6
+ """
7
+
8
+ from matrx_orm import Model, Field
9
+
10
+
11
+ class TestModel(Model):
12
+ """Test model with a field named 'model' to verify no conflicts."""
13
+
14
+ _table_name = "test_models"
15
+ _database = "test"
16
+
17
+ id = Field(primary_key=True)
18
+ name = Field()
19
+ model = Field() # This should now work without conflicts!
20
+ description = Field()
21
+
22
+
23
+ def test_model_definition():
24
+ """Test that the model can be defined with a 'model' field."""
25
+ print("✓ Model definition successful")
26
+ print(f" Table name: {TestModel._table_name}")
27
+ print(f" Fields: {list(TestModel._fields.keys())}")
28
+ assert 'model' in TestModel._fields, "Field 'model' should be in _fields"
29
+ print("✓ Field 'model' is properly defined")
30
+
31
+
32
+ def test_model_instantiation():
33
+ """Test that we can create instances with the 'model' field."""
34
+ instance = TestModel(
35
+ id=1,
36
+ name="Test Item",
37
+ model="GPT-4", # Using 'model' as a field
38
+ description="Test description"
39
+ )
40
+ print("✓ Model instantiation successful")
41
+ print(f" Instance.model: {instance.model}")
42
+ assert instance.model == "GPT-4", "Field 'model' should store the value"
43
+ print("✓ Field 'model' stores and retrieves values correctly")
44
+
45
+
46
+ def test_reserved_names_doc():
47
+ """Verify the RESERVED_NAMES.md file exists."""
48
+ import os
49
+ doc_path = "/home/arman/projects/matrx-orm/RESERVED_NAMES.md"
50
+ assert os.path.exists(doc_path), "RESERVED_NAMES.md should exist"
51
+ print("✓ RESERVED_NAMES.md documentation exists")
52
+
53
+
54
+ if __name__ == "__main__":
55
+ print("=" * 60)
56
+ print("Testing model_cls Refactoring")
57
+ print("=" * 60)
58
+ print()
59
+
60
+ try:
61
+ test_model_definition()
62
+ print()
63
+ test_model_instantiation()
64
+ print()
65
+ test_reserved_names_doc()
66
+ print()
67
+ print("=" * 60)
68
+ print("✅ ALL TESTS PASSED!")
69
+ print("=" * 60)
70
+ print()
71
+ print("Summary:")
72
+ print("- Models can now have fields named 'model' without conflicts")
73
+ print("- Internal operations use 'model_cls' parameter")
74
+ print("- RESERVED_NAMES.md documents all reserved names")
75
+ print()
76
+ except AssertionError as e:
77
+ print()
78
+ print("=" * 60)
79
+ print("❌ TEST FAILED!")
80
+ print("=" * 60)
81
+ print(f"Error: {e}")
82
+ exit(1)
83
+ except Exception as e:
84
+ print()
85
+ print("=" * 60)
86
+ print("❌ UNEXPECTED ERROR!")
87
+ print("=" * 60)
88
+ print(f"Error: {e}")
89
+ import traceback
90
+ traceback.print_exc()
91
+ exit(1)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes