File tree Expand file tree Collapse file tree 1 file changed +34
-1
lines changed Expand file tree Collapse file tree 1 file changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -92,4 +92,37 @@ async def main() -> None:
9292 TextArray([" Foo" , " Bar" , " Cafe" ]),
9393 ],
9494 )
95- ```
95+ ```
96+
97+ ### Cannot insert empty ARRAY
98+
99+ To insert empty array use explicit [ Array Type] ( ./usage/types/array_types.md ) .
100+
101+ #### Problem and Solution:
102+ Let's assume that we have table ` arr_table ` with field ` some_array ` of ` VARCHAR ARRAY ` type.
103+ The main problem that we cannot determine the type of the empty sequence passed from Python side.
104+ ``` python
105+ from psqlpy import ConnectionPool
106+ from psqlpy.extra_types import VarCharArray
107+
108+ # --- Incorrect ---
109+ async def main () -> None :
110+ pool = ConnectionPool()
111+ await pool.execute(
112+ querystring = " INSERT INTO arr_table (some_array) VALUES ($1)" ,
113+ parameters = [
114+ [],
115+ ],
116+ )
117+
118+
119+ # --- Correct ---
120+ async def main () -> None :
121+ pool = ConnectionPool()
122+ await pool.execute(
123+ querystring = " INSERT INTO arr_table (some_array) VALUES ($1)" ,
124+ parameters = [
125+ VarCharArray([]),
126+ ],
127+ )
128+ ```
You can’t perform that action at this time.
0 commit comments