Skip to content

Renamed classes, removed Py prefix #114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions docs/usage/types/extra_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ All extra types available from Python with mapping to PostgreSQL type and Rust t
| SmallInt | SmallInt | i16 |
| Float32 | FLOAT4 | f32 |
| Float64 | FLOAT8 | f64 |
| PyVarChar | VarChar | String |
| PyText | Text | String |
| PyJSON | JSON | serde::Value |
| PyJSONB | JSONB | serde::Value |
| PyMacAddr6 | MacAddr | MacAddr6 |
| PyMacAddr8 | MacAddr8 | MacAddr8 |
| PyPoint | Point | Point |
| PyBox | Rect | Box |
| PyPath | LineString | Path |
| PyLine | LineSegment | Line |
| PyLineSegment | LineSegment | Lseg |
| PyCircle | Circle | Circle |
| VarChar | VarChar | String |
| Text | Text | String |
| JSON | JSON | serde::Value |
| JSONB | JSONB | serde::Value |
| MacAddr6 | MacAddr | MacAddr6 |
| MacAddr8 | MacAddr8 | MacAddr8 |
| Point | Point | Point |
| Box | Rect | Box |
| Path | LineString | Path |
| Line | LineSegment | Line |
| LineSegment | LineSegment | Lseg |
| Circle | Circle | Circle |
| PgVector | Vector | Vector |

::: important
Expand Down Expand Up @@ -208,7 +208,7 @@ Let's assume we have table `geo_info` with all PostgreSQL geo types in the datab
from typing import Final

from psqlpy import ConnectionPool, QueryResult
from psqlpy.extra_types import PyPoint, PyBox, PyPath, PyLine, PyLineSegment, PyCircle
from psqlpy.extra_types import Point, Box, Path, Line, LineSegment, Circle


async def main() -> None:
Expand All @@ -218,12 +218,12 @@ async def main() -> None:
await db_pool.execute(
"INSERT INTO geo_info VALUES ($1, $2, $3, $4, $5, $6)",
[
PyPoint([1.5, 2]),
PyBox([(1.7, 2.8), (9, 9)]),
PyPath([(3.5, 3), (9, 9), (8, 8)]),
PyLine([1, -2, 3]),
PyLineSegment([(5.6, 3.1), (4, 5)]),
PyCircle([5, 1.8, 10]),
Point([1.5, 2]),
Box([(1.7, 2.8), (9, 9)]),
Path([(3.5, 3), (9, 9), (8, 8)]),
Line([1, -2, 3]),
LineSegment([(5.6, 3.1), (4, 5)]),
Circle([5, 1.8, 10]),
],
)

Expand Down
24 changes: 12 additions & 12 deletions docs/usage/types/supported_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ Here you can find all types supported by `PSQLPy`. If PSQLPy isn't `-`, you can
| bool | - | BOOL |
| bytes | - | BYTEA |
| str | - | VARCHAR |
| str | PyVarChar | VARCHAR |
| str | PyText | TEXT |
| str | VarChar | VARCHAR |
| str | Text | TEXT |
| str | - | XML |
| int | SmallInt | SMALLINT |
| int | INTEGER | INTEGER |
Expand All @@ -28,20 +28,20 @@ Here you can find all types supported by `PSQLPy`. If PSQLPy isn't `-`, you can
| datetime.timedelta | - | INTERVAL |
| UUID | - | UUID |
| dict | - | JSONB |
| dict | PyJSONB | JSONB |
| dict | PyJSON | JSON |
| Mac Address 6 | PyMacAddr6 | MacAddr |
| Mac Address 8 | PyMacAddr8 | MacAddr |
| dict | JSONB | JSONB |
| dict | JSON | JSON |
| Mac Address 6 | MacAddr6 | MacAddr |
| Mac Address 8 | MacAddr8 | MacAddr |
| IPv4Address | - | INET |
| IPv6Address | - | INET |
| decimal.Decimal | - | NUMERIC |
| int/str | Money | MONEY |
| Point | PyPoint | POINT |
| Box | PyBox | BOX |
| Path | PyPath | PATH |
| Line | PyLine | LINE |
| Line Segment | PyLineSegment | LSEG |
| Circle | PyCircle | CIRCLE |
| Point | Point | POINT |
| Box | Box | BOX |
| Path | Path | PATH |
| Line | Line | LINE |
| Line Segment | LineSegment | LSEG |
| Circle | Circle | CIRCLE |
| PgVector | PgVector | Vector |

::: important
Expand Down
64 changes: 32 additions & 32 deletions python/psqlpy/_internal/extra_types.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class Float64:
- `inner_value`: float object.
"""

class PyVarChar:
class VarChar:
"""Represent VarChar in PostgreSQL and String in Rust."""

def __init__(self: Self, inner_value: str) -> None:
Expand All @@ -78,7 +78,7 @@ class PyVarChar:
- `inner_value`: str object.
"""

class PyText:
class Text:
"""Represent TEXT in PostgreSQL and String ins Rust."""

def __init__(self: Self, inner_value: str) -> None:
Expand All @@ -90,7 +90,7 @@ class PyText:
- `inner_value`: str object.
"""

class PyJSONB:
class JSONB:
"""Represent JSONB field in PostgreSQL and Value in Rust."""

def __init__(
Expand All @@ -105,7 +105,7 @@ class PyJSONB:
- `value`: value for the JSONB field.
"""

class PyJSON:
class JSON:
"""Represent JSON field in PostgreSQL and Value in Rust."""

def __init__(
Expand All @@ -120,7 +120,7 @@ class PyJSON:
- `value`: value for the JSONB field.
"""

class PyMacAddr6:
class MacAddr6:
"""Represents MACADDR in PostgreSQL."""

def __init__(self, value: str) -> None:
Expand All @@ -130,7 +130,7 @@ class PyMacAddr6:
- `value`: value for MACADDR field.
"""

class PyMacAddr8:
class MacAddr8:
"""Represents MACADDR8 in PostgreSQL."""

def __init__(self, value: str) -> None:
Expand All @@ -140,19 +140,19 @@ class PyMacAddr8:
- `value`: value for MACADDR8 field.
"""

class PyCustomType:
class CustomType:
def __init__(self, value: bytes) -> None: ...

Coordinates: TypeAlias = list[int | float] | set[int | float] | tuple[int | float, int | float]
PairsOfCoordinates: TypeAlias = (
list[Coordinates | int | float] | set[Coordinates | int | float] | tuple[Coordinates | int | float, ...]
)

class PyPoint:
class Point:
"""Represent point field in PostgreSQL and Point in Rust."""

def __init__(self: Self, value: Coordinates) -> None:
"""Create new instance of PyPoint.
"""Create new instance of Point.

It accepts any pair(List, Tuple or Set)
of int/float numbers in every combination.
Expand All @@ -161,11 +161,11 @@ class PyPoint:
- `value`: pair of int/float numbers in every combination.
"""

class PyBox:
class Box:
"""Represent box field in PostgreSQL and Rect in Rust."""

def __init__(self: Self, value: PairsOfCoordinates) -> None:
"""Create new instance of PyBox.
"""Create new instance of Box.

You need to pass any of this structures:
- sequence(List, Tuple or Set) of two sequences(List, Tuple or Set),
Expand All @@ -177,11 +177,11 @@ class PyBox:
of int/float numbers in every combination.
"""

class PyPath:
class Path:
"""Represent path field in PostgreSQL and LineString in Rust."""

def __init__(self: Self, value: PairsOfCoordinates) -> None:
"""Create new instance of PyPath.
"""Create new instance of Path.

You need to pass any of this structures:
- sequence(List, Tuple or Set) of sequences(List, Tuple or Set),
Expand All @@ -193,11 +193,11 @@ class PyPath:
- `value`: any valid structure with int/float numbers in every combination.
"""

class PyLine:
class Line:
"""Represent line field in PostgreSQL and LineSegment in Rust."""

def __init__(self: Self, value: PairsOfCoordinates) -> None:
"""Create new instance of PyLine.
"""Create new instance of Line.

You need to pass any of this structures:
- sequence of three int/float numbers(a, b, c)
Expand All @@ -206,11 +206,11 @@ class PyLine:
- `value`: any valid structure with int/float numbers.
"""

class PyLineSegment:
class LineSegment:
"""Represent lseg field in PostgreSQL and LineSegment in Rust."""

def __init__(self: Self, value: PairsOfCoordinates) -> None:
"""Create new instance of PyLineSegment.
"""Create new instance of LineSegment.

You need to pass any of this structures:
- sequence(List, Tuple or Set) of two sequences(List, Tuple or Set),
Expand All @@ -222,14 +222,14 @@ class PyLineSegment:
- `value`: any valid structure with int/float numbers in every combination.
"""

class PyCircle:
class Circle:
"""Represent circle field in PostgreSQL and Circle in Rust."""

def __init__(
self: Self,
value: list[int | float] | set[int | float] | tuple[int | float, int | float, int | float],
) -> None:
"""Create new instance of PyCircle.
"""Create new instance of Circle.

You need to pass any of this structures:
- sequence of three int/float numbers(x, y, r)
Expand Down Expand Up @@ -390,9 +390,9 @@ class JSONBArray:
self: Self,
inner: typing.Sequence[
dict[str, typing.Any]
| PyJSONB
| JSONB
| typing.Sequence[dict[str, typing.Any]]
| typing.Sequence[PyJSONB]
| typing.Sequence[JSONB]
| typing.Sequence[typing.Any]
],
) -> None:
Expand All @@ -409,9 +409,9 @@ class JSONArray:
self: Self,
inner: typing.Sequence[
dict[str, typing.Any]
| PyJSON
| JSON
| typing.Sequence[dict[str, typing.Any]]
| typing.Sequence[PyJSON]
| typing.Sequence[JSON]
| typing.Sequence[typing.Any]
],
) -> None:
Expand Down Expand Up @@ -478,7 +478,7 @@ class MacAddr6Array:

def __init__(
self: Self,
inner: typing.Sequence[PyMacAddr6 | typing.Sequence[PyMacAddr6] | typing.Any,],
inner: typing.Sequence[MacAddr6 | typing.Sequence[MacAddr6] | typing.Any,],
) -> None:
"""Create new instance of MacAddr6Array.

Expand All @@ -491,7 +491,7 @@ class MacAddr8Array:

def __init__(
self: Self,
inner: typing.Sequence[PyMacAddr8 | typing.Sequence[PyMacAddr8] | typing.Any,],
inner: typing.Sequence[MacAddr8 | typing.Sequence[MacAddr8] | typing.Any,],
) -> None:
"""Create new instance of MacAddr8Array.

Expand All @@ -517,7 +517,7 @@ class PointArray:

def __init__(
self: Self,
inner: typing.Sequence[PyPoint | typing.Sequence[PyPoint] | typing.Any,],
inner: typing.Sequence[Point | typing.Sequence[Point] | typing.Any,],
) -> None:
"""Create new instance of PointArray.

Expand All @@ -530,20 +530,20 @@ class BoxArray:

def __init__(
self: Self,
inner: typing.Sequence[PyBox | typing.Sequence[PyBox] | typing.Any,],
inner: typing.Sequence[Box | typing.Sequence[Box] | typing.Any,],
) -> None:
"""Create new instance of BoxArray.

### Parameters:
- `inner`: inner value, sequence of PyBox values.
- `inner`: inner value, sequence of Box values.
"""

class PathArray:
"""Represent PATH ARRAY in PostgreSQL."""

def __init__(
self: Self,
inner: typing.Sequence[PyPath | typing.Sequence[PyPath] | typing.Any,],
inner: typing.Sequence[Path | typing.Sequence[Path] | typing.Any,],
) -> None:
"""Create new instance of PathArray.

Expand All @@ -556,7 +556,7 @@ class LineArray:

def __init__(
self: Self,
inner: typing.Sequence[PyLine | typing.Sequence[PyLine] | typing.Any,],
inner: typing.Sequence[Line | typing.Sequence[Line] | typing.Any,],
) -> None:
"""Create new instance of LineArray.

Expand All @@ -569,7 +569,7 @@ class LsegArray:

def __init__(
self: Self,
inner: typing.Sequence[PyLineSegment | typing.Sequence[PyLineSegment] | typing.Any,],
inner: typing.Sequence[LineSegment | typing.Sequence[LineSegment] | typing.Any,],
) -> None:
"""Create new instance of LsegArray.

Expand All @@ -582,7 +582,7 @@ class CircleArray:

def __init__(
self: Self,
inner: typing.Sequence[PyCircle | typing.Sequence[PyCircle] | typing.Any,],
inner: typing.Sequence[Circle | typing.Sequence[Circle] | typing.Any,],
) -> None:
"""Create new instance of CircleArray.

Expand Down
Loading
Loading