Skip to content

Commit 0bfcacb

Browse files
committed
Merge branch 'feature/return-error-codes' into next
2 parents acd11b8 + 0a5ca23 commit 0bfcacb

5 files changed

Lines changed: 195 additions & 144 deletions

File tree

README.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -99,19 +99,19 @@ Additionally, a video tutorial by [Mitch McCollum (finepointcgi)](https://github
9999

100100
## Methods
101101

102-
- Boolean success = **open_db()**
102+
- ResultCode rc = **open_db()**
103103

104104
Open a new database connection. Multiple concurrently open connections to the same database are possible.
105105

106-
- Boolean success = **close_db()**
106+
- ResultCode rc = **close_db()**
107107

108108
Close the current database connection.
109109

110-
- Boolean success = **query(** String query_string **)**
110+
- ResultCode rc = **query(** String query_string **)**
111111

112112
Query the database using the raw SQL statement defined in `query_string`.
113113

114-
- Boolean success = **query_with_bindings(** String query_string, Array param_bindings **)**
114+
- ResultCode rc = **query_with_bindings(** String query_string, Array param_bindings **)**
115115

116116
Binds the parameters contained in the `param_bindings`-variable to the query. Using this function stops any possible attempts at SQL data injection as the parameters are sanitized. More information regarding parameter bindings can be found [here](https://www.sqlite.org/c3ref/bind_blob.html).
117117

@@ -121,7 +121,7 @@ Additionally, a video tutorial by [Mitch McCollum (finepointcgi)](https://github
121121
var column_name : String = "name";
122122
var query_string : String = "SELECT %s FROM company WHERE age < ?;" % [column_name]
123123
var param_bindings : Array = [24]
124-
var success = db.query_with_bindings(query_string, param_bindings)
124+
var rc = db.query_with_bindings(query_string, param_bindings)
125125
# Executes following query:
126126
# SELECT name FROM company WHERE age < 24;
127127
```
@@ -130,7 +130,7 @@ Additionally, a video tutorial by [Mitch McCollum (finepointcgi)](https://github
130130
131131
***NOTE**: Binding column names is not possible due to SQLite restrictions. If dynamic column names are required, insert the column name directly into the `query_string`-variable itself (see https://github.com/2shady4u/godot-sqlite/issues/41).*
132132
133-
- Boolean success = **create_table(** String table_name, Dictionary table_dictionary **)**
133+
- ResultCode rc = **create_table(** String table_name, Dictionary table_dictionary **)**
134134
135135
Each key/value pair of the `table_dictionary`-variable defines a column of the table. Each key defines the name of a column in the database, while the value is a dictionary that contains further column specifications.
136136
@@ -182,40 +182,40 @@ Additionally, a video tutorial by [Mitch McCollum (finepointcgi)](https://github
182182
183183
For more concrete usage examples see the `database.gd`-file as found in this repository's demo project.
184184
185-
- Boolean success = **drop_table(** String table_name **)**
185+
- ResultCode rc = **drop_table(** String table_name **)**
186186
187187
Drop the table with name `table_name`. This method is equivalent to the following query:
188188
```
189189
db.query("DROP TABLE "+ table_name + ";")
190190
```
191191
192-
- Boolean success = **insert_row(** String table_name, Dictionary row_dictionary **)**
192+
- ResultCode rc = **insert_row(** String table_name, Dictionary row_dictionary **)**
193193
194194
Each key/value pair of the `row_dictionary`-variable defines the column values of a single row.
195195
196196
Columns should adhere to the table schema as instantiated using the `table_dictionary`-variable and are required if their corresponding **"not_null"**-column value is set to `True`.
197197
198-
- Boolean success = **insert_rows(** String table_name, Array row_array **)**
198+
- ResultCode rc = **insert_rows(** String table_name, Array row_array **)**
199199
200200
- Array selected_rows = **select_rows(** String table_name, String query_conditions, Array selected_columns **)**
201201
202202
Returns the results from the latest query **by value**; meaning that this property does not get overwritten by any successive queries.
203203
204-
- Boolean success = **update_rows(** String table_name, String query_conditions, Dictionary updated_row_dictionary **)**
204+
- ResultCode rc = **update_rows(** String table_name, String query_conditions, Dictionary updated_row_dictionary **)**
205205
206206
With the `updated_row_dictionary`-variable adhering to the same table schema & conditions as the `row_dictionary`-variable defined previously.
207207
208-
- Boolean success = **delete_rows(** String table_name, String query_conditions **)**
208+
- ResultCode rc = **delete_rows(** String table_name, String query_conditions **)**
209209
210-
- Boolean success = **import_from_json(** String import_path **)**
210+
- ResultCode rc = **import_from_json(** String import_path **)**
211211
212212
Drops all database tables and imports the database structure and content present inside of `import_path.json`.
213213
214-
- Boolean success = **export_to_json(** String export_path **)**
214+
- ResultCode rc = **export_to_json(** String export_path **)**
215215
216216
Exports the database structure and content to `export_path.json` as a backup or for ease of editing.
217217
218-
- Boolean success = **import_from_buffer(** PackedByteArray input_buffer **)**
218+
- ResultCode rc = **import_from_buffer(** PackedByteArray input_buffer **)**
219219
220220
Drops all database tables and imports the database structure and content encoded in JSON-formatted input_buffer.
221221
@@ -227,7 +227,7 @@ Additionally, a video tutorial by [Mitch McCollum (finepointcgi)](https://github
227227
228228
Can be used together with `import_from_buffer()` to implement database encryption.
229229
230-
- Boolean success = **create_function(** String function_name, FuncRef function_reference, int number_of_arguments **)**
230+
- ResultCode rc = **create_function(** String function_name, FuncRef function_reference, int number_of_arguments **)**
231231
232232
Bind a [scalar SQL function](https://www.sqlite.org/appfunc.html) to the database that can then be used in subsequent queries.
233233
@@ -246,8 +246,8 @@ Additionally, a video tutorial by [Mitch McCollum (finepointcgi)](https://github
246246
db.compileoption_used("ENABLE_FTS5") # The "SQLITE_"-prefix may be omitted.
247247
```
248248
249-
- Boolean success = **backup_to(** String destination_path **)**
250-
- Boolean success = **restore_from(** String source_path **)**
249+
- ResultCode rc = **backup_to(** String destination_path **)**
250+
- ResultCode rc = **restore_from(** String source_path **)**
251251
252252
Backup or restore the current database to/from a path, see [here](https://www.sqlite.org/backup.html). This feature is useful if you are using a database as your save file and you want to easily implement a saving/loading mechanic. Be warned that the original database will be overwritten entirely when restoring.
253253

demo/icon.png.import

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,19 @@ dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.cte
1818
compress/mode=0
1919
compress/high_quality=false
2020
compress/lossy_quality=0.7
21+
compress/uastc_level=0
22+
compress/rdo_quality_loss=0.0
2123
compress/hdr_compression=1
2224
compress/normal_map=0
2325
compress/channel_pack=0
2426
mipmaps/generate=false
2527
mipmaps/limit=-1
2628
roughness/mode=0
2729
roughness/src_normal=""
30+
process/channel_remap/red=0
31+
process/channel_remap/green=1
32+
process/channel_remap/blue=2
33+
process/channel_remap/alpha=3
2834
process/fix_alpha_border=true
2935
process/premult_alpha=false
3036
process/normal_map_invert_y=false

doc_classes/SQLite.xml

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,33 +48,33 @@
4848
</tutorials>
4949
<methods>
5050
<method name="open_db">
51-
<return type="bool" />
51+
<return type="ResultCode" />
5252
<description>
5353
Open a new database connection. Multiple concurrently open connections to the same database are possible.
5454
</description>
5555
</method>
5656
<method name="close_db">
57-
<return type="bool" />
57+
<return type="ResultCode" />
5858
<description>
5959
Close the current database connection.
6060
</description>
6161
</method>
6262
<method name="query">
63-
<return type="bool" />
63+
<return type="ResultCode" />
6464
<description>
6565
Query the database using the raw SQL statement defined in [code]query_string[/code].
6666
</description>
6767
</method>
6868
<method name="query_with_bindings">
69-
<return type="bool" />
69+
<return type="ResultCode" />
7070
<description>
7171
Binds the parameters contained in the [code]param_bindings[/code]-variable to the query. Using this function stops any possible attempts at SQL data injection as the parameters are sanitized. More information regarding parameter bindings can be found [url=https://www.sqlite.org/c3ref/bind_blob.html]here[/url].
7272
[b]Example usage[/b]:
7373
[codeblock]
7474
var column_name : String = "name"
7575
var query_string : String = "SELECT %s FROM company WHERE age &lt; ?;" % [column_name]
7676
var param_bindings : Array = [24]
77-
var success = db.query_with_bindings(query_string, param_bindings)
77+
var rc = db.query_with_bindings(query_string, param_bindings)
7878
# Executes following query:
7979
# SELECT name FROM company WHERE age &lt; 24;
8080
[/codeblock]
@@ -83,7 +83,7 @@
8383
</description>
8484
</method>
8585
<method name="create_table">
86-
<return type="bool" />
86+
<return type="ResultCode" />
8787
<description>
8888
Each key/value pair of the [code]table_dictionary[/code]-variable defines a column of the table. Each key defines the name of a column in the database, while the value is a dictionary that contains further column specifications.
8989
[b]Required fields[/b]:
@@ -111,7 +111,7 @@
111111
</description>
112112
</method>
113113
<method name="drop_table">
114-
<return type="bool" />
114+
<return type="ResultCode" />
115115
<description>
116116
Drop the table with name [code]table_name[/code]. This method is equivalent to the following query:
117117
[codeblock]
@@ -120,14 +120,14 @@
120120
</description>
121121
</method>
122122
<method name="insert_row">
123-
<return type="bool" />
123+
<return type="ResultCode" />
124124
<description>
125125
Each key/value pair of the [code]row_dictionary[/code]-variable defines the column values of a single row.
126126
Columns should adhere to the table schema as instantiated using the [code]table_dictionary[/code]-variable and are required if their corresponding [b]"not_null"[/b]-column value is set to [code]True[/code].
127127
</description>
128128
</method>
129129
<method name="insert_rows">
130-
<return type="bool" />
130+
<return type="ResultCode" />
131131
<description>
132132
Insert multiple rows into the given table. The [code]row_array[/code] input argument should be an array of dictionaries where each element is defined as in [method insert_row].
133133
</description>
@@ -139,31 +139,31 @@
139139
</description>
140140
</method>
141141
<method name="update_rows">
142-
<return type="bool" />
142+
<return type="ResultCode" />
143143
<description>
144144
With the [code]updated_row_dictionary[/code]-variable adhering to the same table schema &amp; conditions as the [code]row_dictionary[/code]-variable defined previously.
145145
</description>
146146
</method>
147147
<method name="delete_rows">
148-
<return type="bool" />
148+
<return type="ResultCode" />
149149
<description>
150150
Delete all rows of the table that match the given conditions.
151151
</description>
152152
</method>
153153
<method name="import_from_json">
154-
<return type="bool" />
154+
<return type="ResultCode" />
155155
<description>
156156
Drops all database tables and imports the database structure and content present inside of [code]import_path.json[/code].
157157
</description>
158158
</method>
159159
<method name="export_to_json">
160-
<return type="bool" />
160+
<return type="ResultCode" />
161161
<description>
162162
Exports the database structure and content to [code]export_path.json[/code] as a backup or for ease of editing.
163163
</description>
164164
</method>
165165
<method name="import_from_buffer">
166-
<return type="bool" />
166+
<return type="ResultCode" />
167167
<description>
168168
Drops all database tables and imports the database structure and content encoded in JSON-formatted input buffer.
169169
Can be used together with [method SQLite.export_to_buffer] to implement database encryption.
@@ -177,7 +177,7 @@
177177
</description>
178178
</method>
179179
<method name="create_function">
180-
<return type="bool" />
180+
<return type="ResultCode" />
181181
<description>
182182
Bind a [url=https://www.sqlite.org/appfunc.html]scalar SQL function[/url] to the database that can then be used in subsequent queries.
183183
</description>
@@ -189,13 +189,13 @@
189189
</description>
190190
</method>
191191
<method name="backup_to">
192-
<return type="bool" />
192+
<return type="ResultCode" />
193193
<description>
194194
Backup the current database to a path, see [url=https://www.sqlite.org/backup.html]here[/url]. This feature is useful if you are using a database as your save file and you want to easily implement a saving mechanic.
195195
</description>
196196
</method>
197197
<method name="restore_from">
198-
<return type="bool" />
198+
<return type="ResultCode" />
199199
<description>
200200
Restore the current database from a path, see [url=https://www.sqlite.org/backup.html]here[/url]. This feature is useful if you are using a database as your save file and you want to easily implement a loading mechanic. Be warned that the original database will be overwritten entirely when restoring.
201201
</description>
@@ -289,5 +289,8 @@
289289
<constant name="VERY_VERBOSE" value="3">
290290
Same as [constant VERBOSE].
291291
</constant>
292+
<constant name="RC_GDSQLITE_ERROR" value="10000">
293+
Error that does not correspond to any of the result codes defined by SQLite.
294+
</constant>
292295
</constants>
293296
</class>

0 commit comments

Comments
 (0)