Skip to content
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

On conflict clause / upserts #816

Merged
merged 32 commits into from
May 3, 2023
Merged
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
6533ee4
initial commit
dantownsend Apr 27, 2023
0ee5c89
fix tests
dantownsend Apr 28, 2023
c58dbbc
version pin litestar
dantownsend Apr 28, 2023
ccc1538
use typing extensions for Literal
dantownsend Apr 28, 2023
03287bc
make suggested change
dantownsend Apr 28, 2023
87afd15
undo
dantownsend Apr 28, 2023
745630a
Update piccolo/query/mixins.py
dantownsend Apr 28, 2023
d32b89b
Update piccolo/query/mixins.py
dantownsend Apr 28, 2023
85ee5a0
add one extra comma
dantownsend Apr 28, 2023
5623bc8
Merge branch '252-on-conflict-clause' of github.com:telerytech/piccol…
dantownsend Apr 28, 2023
e171a1a
first attempt at docs
dantownsend Apr 28, 2023
96a2257
add `NotImplementedError` for unsupported methods
dantownsend Apr 29, 2023
84cd6ec
fix typo in sqlite version number
dantownsend Apr 29, 2023
627528d
fix tests
dantownsend Apr 29, 2023
aa3d0a0
get tests running for sqlite
dantownsend Apr 30, 2023
8c42dcc
add test for `do nothing`
dantownsend Apr 30, 2023
850481d
add test for violating non target constraint
dantownsend Apr 30, 2023
a29d9f7
remove old comment
dantownsend Apr 30, 2023
6363990
allow multiple on conflict clauses
dantownsend Apr 30, 2023
a9c3e6e
`target` -> `targets`
dantownsend Apr 30, 2023
ee32a1b
add docstring for `test_do_nothing`
dantownsend Apr 30, 2023
ae973ec
add tests for multiple ON CONFLICT clauses
dantownsend Apr 30, 2023
78415d4
add docs for multiple ``on_conflict`` clauses
dantownsend Apr 30, 2023
455200b
add docs for using `all_columns`
dantownsend Apr 30, 2023
d20afff
fix typo in test name
dantownsend Apr 30, 2023
11de6f6
add test for using `all_columns`
dantownsend Apr 30, 2023
ba0e8e2
add test for using an enum to specify the action
dantownsend Apr 30, 2023
0d2ce6d
add a test to make sure `DO UPDATE` with no values raises an exception
dantownsend Apr 30, 2023
bbe4c6f
rename `targets` back to `target`
dantownsend May 2, 2023
2f3881a
integrate @sinisaos tests
dantownsend May 2, 2023
54c02da
move `on_conflict` to its own page
dantownsend May 3, 2023
8c4a99c
refactor the `where` clause
dantownsend May 3, 2023
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
Prev Previous commit
Next Next commit
use typing extensions for Literal
dantownsend committed Apr 28, 2023
commit ccc15389371bf539785f0b72dff2369fa8fa2283
4 changes: 3 additions & 1 deletion piccolo/query/methods/insert.py
Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@

import typing as t

from typing_extensions import Literal

from piccolo.custom_types import TableInstance
from piccolo.query.base import Query
from piccolo.query.mixins import (
@@ -46,7 +48,7 @@ def on_conflict(
self: Self,
target: t.Optional[t.Sequence[t.Union[str, Column]]] = None,
action: t.Union[
OnConflictAction, t.Literal["DO NOTHING", "DO UPDATE"]
OnConflictAction, Literal["DO NOTHING", "DO UPDATE"]
] = OnConflictAction.do_nothing,
values: t.Optional[
t.List[t.Union[Column, t.Tuple[t.Union[str, Column], t.Any]]]
4 changes: 3 additions & 1 deletion piccolo/query/mixins.py
Original file line number Diff line number Diff line change
@@ -7,6 +7,8 @@
from dataclasses import dataclass, field
from enum import Enum, auto

from typing_extensions import Literal

from piccolo.columns import And, Column, Or, Where
from piccolo.columns.column_types import ForeignKey
from piccolo.custom_types import Combinable
@@ -726,7 +728,7 @@ def on_conflict(
self,
target: t.Optional[t.Sequence[t.Union[str, Column]]] = None,
action: t.Union[
OnConflictAction, t.Literal["DO NOTHING", "DO UPDATE"]
OnConflictAction, Literal["DO NOTHING", "DO UPDATE"]
] = OnConflictAction.do_nothing,
values: t.Optional[
t.List[t.Union[Column, t.Tuple[t.Union[str, Column], t.Any]]]