relations-postgresql 0.6.4__tar.gz → 0.6.5__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 (22) hide show
  1. {relations_postgresql-0.6.4 → relations_postgresql-0.6.5}/PKG-INFO +2 -2
  2. {relations_postgresql-0.6.4 → relations_postgresql-0.6.5}/lib/relations_postgresql/column.py +29 -2
  3. {relations_postgresql-0.6.4 → relations_postgresql-0.6.5}/lib/relations_postgresql.egg-info/PKG-INFO +2 -2
  4. relations_postgresql-0.6.5/lib/relations_postgresql.egg-info/requires.txt +1 -0
  5. {relations_postgresql-0.6.4 → relations_postgresql-0.6.5}/setup.py +1 -1
  6. relations_postgresql-0.6.4/lib/relations_postgresql.egg-info/requires.txt +0 -1
  7. {relations_postgresql-0.6.4 → relations_postgresql-0.6.5}/LICENSE.txt +0 -0
  8. {relations_postgresql-0.6.4 → relations_postgresql-0.6.5}/README.md +0 -0
  9. {relations_postgresql-0.6.4 → relations_postgresql-0.6.5}/lib/relations_postgresql/__init__.py +0 -0
  10. {relations_postgresql-0.6.4 → relations_postgresql-0.6.5}/lib/relations_postgresql/clause.py +0 -0
  11. {relations_postgresql-0.6.4 → relations_postgresql-0.6.5}/lib/relations_postgresql/criteria.py +0 -0
  12. {relations_postgresql-0.6.4 → relations_postgresql-0.6.5}/lib/relations_postgresql/criterion.py +0 -0
  13. {relations_postgresql-0.6.4 → relations_postgresql-0.6.5}/lib/relations_postgresql/ddl.py +0 -0
  14. {relations_postgresql-0.6.4 → relations_postgresql-0.6.5}/lib/relations_postgresql/expression.py +0 -0
  15. {relations_postgresql-0.6.4 → relations_postgresql-0.6.5}/lib/relations_postgresql/index.py +0 -0
  16. {relations_postgresql-0.6.4 → relations_postgresql-0.6.5}/lib/relations_postgresql/query.py +0 -0
  17. {relations_postgresql-0.6.4 → relations_postgresql-0.6.5}/lib/relations_postgresql/sql.py +0 -0
  18. {relations_postgresql-0.6.4 → relations_postgresql-0.6.5}/lib/relations_postgresql/table.py +0 -0
  19. {relations_postgresql-0.6.4 → relations_postgresql-0.6.5}/lib/relations_postgresql.egg-info/SOURCES.txt +0 -0
  20. {relations_postgresql-0.6.4 → relations_postgresql-0.6.5}/lib/relations_postgresql.egg-info/dependency_links.txt +0 -0
  21. {relations_postgresql-0.6.4 → relations_postgresql-0.6.5}/lib/relations_postgresql.egg-info/top_level.txt +0 -0
  22. {relations_postgresql-0.6.4 → relations_postgresql-0.6.5}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: relations-postgresql
3
- Version: 0.6.4
3
+ Version: 0.6.5
4
4
  Home-page: https://github.com/relations-dil/python-relations-postgresql
5
5
  Author: Gaffer Fitch
6
6
  Author-email: relations@gaf3.com
@@ -8,7 +8,7 @@ Classifier: Programming Language :: Python :: 3
8
8
  Classifier: License :: OSI Approved :: MIT License
9
9
  Description-Content-Type: text/markdown
10
10
  License-File: LICENSE.txt
11
- Requires-Dist: relations-sql>=0.6.10
11
+ Requires-Dist: relations-sql>=0.6.11
12
12
  Dynamic: author
13
13
  Dynamic: author-email
14
14
  Dynamic: classifier
@@ -30,6 +30,26 @@ class COLUMN(relations_postgresql.DDL, relations_sql.COLUMN):
30
30
  SET_NONE = """ALTER %s SET NOT NULL"""
31
31
  UNSET_NONE = """ALTER %s DROP NOT NULL"""
32
32
 
33
+ def cast(self, kind, length):
34
+ """
35
+ Get the type of a kind, a str with a length being that long
36
+ """
37
+
38
+ if kind == "str" and length:
39
+ return f"VARCHAR({length})"
40
+
41
+ return self.KINDS.get(kind, self.KINDS["json"])
42
+
43
+ def create(self, **kwargs):
44
+ """
45
+ CREATE DLL, a str with a length being that long
46
+ """
47
+
48
+ super().create(**kwargs)
49
+
50
+ if self.migration.get("kind") == "str" and self.migration.get("length") and "__" not in self.migration["store"]:
51
+ self.sql = self.sql.replace(self.KINDS["str"], self.cast("str", self.migration["length"]), 1)
52
+
33
53
  def extract(self, kind, sql, **kwargs):
34
54
  """
35
55
  Get extract DDL
@@ -45,15 +65,22 @@ class COLUMN(relations_postgresql.DDL, relations_sql.COLUMN):
45
65
  Modifies the kind
46
66
  """
47
67
 
48
- cast = self.KINDS.get(self.migration.get("kind", self.definition["kind"]), self.KINDS["json"])
68
+ cast = self.cast(
69
+ self.migration.get("kind", self.definition["kind"]),
70
+ self.migration.get("length", self.definition.get("length"))
71
+ )
49
72
 
50
73
  sql.append(f'ALTER {self.name()} TYPE {cast} USING {self.name()}::{cast}')
51
74
 
52
75
  def modify(self, indent=0, count=0, pad=' ', **kwargs):
53
76
  """
54
- MODIFY DLL, an id that stops being an auto int also loses the sequence default BIGSERIAL gave it
77
+ MODIFY DLL, an id that stops being an auto int also loses the sequence default BIGSERIAL gave it, and a
78
+ str changing its length gets a new kind
55
79
  """
56
80
 
81
+ if "length" in self.migration and "kind" not in self.migration and self.definition["kind"] == "str":
82
+ self.migration = {**self.migration, "kind": "str"}
83
+
57
84
  super().modify(indent=indent, count=count, pad=pad, **kwargs)
58
85
 
59
86
  migration = self.migration
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: relations-postgresql
3
- Version: 0.6.4
3
+ Version: 0.6.5
4
4
  Home-page: https://github.com/relations-dil/python-relations-postgresql
5
5
  Author: Gaffer Fitch
6
6
  Author-email: relations@gaf3.com
@@ -8,7 +8,7 @@ Classifier: Programming Language :: Python :: 3
8
8
  Classifier: License :: OSI Approved :: MIT License
9
9
  Description-Content-Type: text/markdown
10
10
  License-File: LICENSE.txt
11
- Requires-Dist: relations-sql>=0.6.10
11
+ Requires-Dist: relations-sql>=0.6.11
12
12
  Dynamic: author
13
13
  Dynamic: author-email
14
14
  Dynamic: classifier
@@ -0,0 +1 @@
1
+ relations-sql>=0.6.11
@@ -30,7 +30,7 @@ setup(
30
30
  'relations_postgresql.table'
31
31
  ],
32
32
  install_requires=[
33
- 'relations-sql>=0.6.10'
33
+ 'relations-sql>=0.6.11'
34
34
  ],
35
35
  url="https://github.com/relations-dil/python-relations-postgresql",
36
36
  author="Gaffer Fitch",
@@ -1 +0,0 @@
1
- relations-sql>=0.6.10