sqlalchemy-postgres-point 0.2.1__py3-none-any.whl → 0.2.2__py3-none-any.whl
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.
- sqlalchemy_postgres_point/__init__.py +0 -0
- sqlalchemy_postgres_point/point.py +1 -2
- {sqlalchemy_postgres_point-0.2.1.dist-info → sqlalchemy_postgres_point-0.2.2.dist-info}/METADATA +23 -11
- sqlalchemy_postgres_point-0.2.2.dist-info/RECORD +7 -0
- {sqlalchemy_postgres_point-0.2.1.dist-info → sqlalchemy_postgres_point-0.2.2.dist-info}/WHEEL +1 -1
- sqlalchemy_postgres_point-0.2.1.dist-info/RECORD +0 -7
|
File without changes
|
|
@@ -11,7 +11,6 @@ References:
|
|
|
11
11
|
|
|
12
12
|
import math
|
|
13
13
|
import re
|
|
14
|
-
from typing import Tuple
|
|
15
14
|
|
|
16
15
|
from sqlalchemy.types import Float, UserDefinedType
|
|
17
16
|
|
|
@@ -23,7 +22,7 @@ class PointType(UserDefinedType):
|
|
|
23
22
|
return "POINT"
|
|
24
23
|
|
|
25
24
|
@staticmethod
|
|
26
|
-
def _validate_point(value:
|
|
25
|
+
def _validate_point(value: tuple[float, float]) -> tuple[float, float]:
|
|
27
26
|
"""Validate and normalize a (lng, lat) tuple.
|
|
28
27
|
|
|
29
28
|
- Ensures it's a 2-length tuple/list
|
{sqlalchemy_postgres_point-0.2.1.dist-info → sqlalchemy_postgres_point-0.2.2.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: sqlalchemy-postgres-point
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Lightweight SQLAlchemy custom type for PostgreSQL POINT columns with tuple binding and an earth-distance comparator.
|
|
5
5
|
Keywords: sqlalchemy,postgresql,point,geometry,geospatial,gis,database,types,earthdistance
|
|
6
6
|
Author: Michael Bianco
|
|
@@ -46,7 +46,7 @@ from sqlalchemy_postgres_point import PointType
|
|
|
46
46
|
|
|
47
47
|
|
|
48
48
|
class Base(DeclarativeBase):
|
|
49
|
-
|
|
49
|
+
pass
|
|
50
50
|
|
|
51
51
|
|
|
52
52
|
class Place(Base):
|
|
@@ -55,6 +55,7 @@ class Place(Base):
|
|
|
55
55
|
# Store as (longitude, latitude)
|
|
56
56
|
location = Column(PointType)
|
|
57
57
|
|
|
58
|
+
|
|
58
59
|
# Example query using the custom comparator
|
|
59
60
|
from sqlalchemy import select
|
|
60
61
|
|
|
@@ -80,14 +81,15 @@ Revises: your_previous_revision
|
|
|
80
81
|
Create Date: 2025-01-XX XX:XX:XX.XXXXXX
|
|
81
82
|
|
|
82
83
|
"""
|
|
84
|
+
|
|
83
85
|
from typing import Sequence, Union
|
|
84
86
|
|
|
85
87
|
from alembic import op
|
|
86
88
|
import sqlalchemy as sa
|
|
87
89
|
|
|
88
90
|
# revision identifiers, used by Alembic.
|
|
89
|
-
revision: str =
|
|
90
|
-
down_revision: Union[str, None] =
|
|
91
|
+
revision: str = "your_revision_id"
|
|
92
|
+
down_revision: Union[str, None] = "your_previous_revision"
|
|
91
93
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
92
94
|
depends_on: Union[str, Sequence[str], None] = None
|
|
93
95
|
|
|
@@ -118,15 +120,16 @@ Values are loaded as a 2-tuple of floats `(lng, lat)` or `None` when NULL.
|
|
|
118
120
|
|
|
119
121
|
## Alembic Integration
|
|
120
122
|
|
|
121
|
-
To ensure generated migration files include the correct `PointType` import, pass the provided `render_item` hook to `context.configure()` in your `alembic/env.py`:
|
|
123
|
+
To ensure generated migration files include the correct `PointType` import, pass the provided `render_item` hook to `context.configure()` in your `alembic/env.py`. This must be added to **both** `run_migrations_online` and `run_migrations_offline`:
|
|
122
124
|
|
|
123
125
|
```python
|
|
124
|
-
from sqlalchemy_postgres_point.alembic_integration import
|
|
126
|
+
from sqlalchemy_postgres_point.alembic_integration import (
|
|
127
|
+
render_item as render_point_item,
|
|
128
|
+
)
|
|
125
129
|
|
|
126
|
-
# in run_migrations_online and run_migrations_offline:
|
|
127
130
|
context.configure(
|
|
128
131
|
# ... other options ...
|
|
129
|
-
render_item=
|
|
132
|
+
render_item=render_point_item,
|
|
130
133
|
)
|
|
131
134
|
```
|
|
132
135
|
|
|
@@ -134,17 +137,26 @@ Once wired up, `from sqlalchemy_postgres_point import PointType` will be automat
|
|
|
134
137
|
|
|
135
138
|
### Chaining `render_item`
|
|
136
139
|
|
|
137
|
-
|
|
140
|
+
If you need to combine this with other packages that also provide a `render_item`, chain them:
|
|
138
141
|
|
|
139
142
|
```python
|
|
140
|
-
from sqlalchemy_postgres_point.alembic_integration import
|
|
143
|
+
from sqlalchemy_postgres_point.alembic_integration import (
|
|
144
|
+
render_item as render_point_item,
|
|
145
|
+
)
|
|
146
|
+
|
|
141
147
|
|
|
142
148
|
def render_item(type_, obj, autogen_context):
|
|
143
149
|
return (
|
|
144
|
-
|
|
150
|
+
render_point_item(type_, obj, autogen_context)
|
|
145
151
|
or other_package.render_item(type_, obj, autogen_context)
|
|
146
152
|
or False
|
|
147
153
|
)
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
context.configure(
|
|
157
|
+
# ... other options ...
|
|
158
|
+
render_item=render_item,
|
|
159
|
+
)
|
|
148
160
|
```
|
|
149
161
|
|
|
150
162
|
Or you could use something like [`some_fn`](https://funcy.readthedocs.io/en/stable/funcs.html#some_fn) to make this even cleaner.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
sqlalchemy_postgres_point/__init__.py,sha256=BWlOd4qbAt4fM4cclR7ZrzZ-aib0f13KD3HIKmod2_s,208
|
|
2
|
+
sqlalchemy_postgres_point/alembic_integration.py,sha256=T7VzTFNAlsI3_HMnnpwWNWTuXisJjfTxYlo8YW6KDE4,1015
|
|
3
|
+
sqlalchemy_postgres_point/point.py,sha256=x0j76v6nihBb6yaXdQsM3CrNcYbf_jhfk0uEEeSaL1U,2863
|
|
4
|
+
sqlalchemy_postgres_point/utils.py,sha256=Loc9Q-xkntEKP3WSw48rZr64aqPWdM9huBlJnGuZa_8,1340
|
|
5
|
+
sqlalchemy_postgres_point-0.2.2.dist-info/WHEEL,sha256=wXwAVsgVaOZ_pwDFqQm5Rd6PID-Fc74nkLc8X8gHiDo,81
|
|
6
|
+
sqlalchemy_postgres_point-0.2.2.dist-info/METADATA,sha256=eVs-JfQP4sHPrERXl0WuL6K00YPLWY3qUXJ4DIHr_h8,6210
|
|
7
|
+
sqlalchemy_postgres_point-0.2.2.dist-info/RECORD,,
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
sqlalchemy_postgres_point/__init__.py,sha256=BWlOd4qbAt4fM4cclR7ZrzZ-aib0f13KD3HIKmod2_s,208
|
|
2
|
-
sqlalchemy_postgres_point/alembic_integration.py,sha256=T7VzTFNAlsI3_HMnnpwWNWTuXisJjfTxYlo8YW6KDE4,1015
|
|
3
|
-
sqlalchemy_postgres_point/point.py,sha256=pb_aoNKwMOaKJ_xDvaIhfE-4VZKzyiPgOWmM6_z6xXo,2888
|
|
4
|
-
sqlalchemy_postgres_point/utils.py,sha256=Loc9Q-xkntEKP3WSw48rZr64aqPWdM9huBlJnGuZa_8,1340
|
|
5
|
-
sqlalchemy_postgres_point-0.2.1.dist-info/WHEEL,sha256=AKeAJsuKQDVE1yEMr94YEC7FtwPuFZZw2DmbXPmgtaE,81
|
|
6
|
-
sqlalchemy_postgres_point-0.2.1.dist-info/METADATA,sha256=cJGmSMFbUeqQsNqkph63jiuFIWnX16Zraa5vY9l_Nc8,6041
|
|
7
|
-
sqlalchemy_postgres_point-0.2.1.dist-info/RECORD,,
|