Skip to content
This repository was archived by the owner on Jul 20, 2023. It is now read-only.

Commit 287bbe2

Browse files
authored
Update PostgreSQLClient.gd
1 parent 478e09f commit 287bbe2

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

PostgreSQLClient.gd

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,13 @@ class PostgreSQLQueryResult:
513513
## These elements are native GDscript types that represent the data resulting from the query.
514514
var data_row := []
515515

516-
## No use
516+
## An Array that contains sub-arrays.
517+
## These sub-arrays represent for most of the queries the rows of the table where the query was executed.
518+
## The number of sub-tables depends on the query that has been made.
519+
## These sub-arrays contain as many elements as number_of_fields_in_a_row.
520+
## Unlike data_row which contains elements of native GDscript types, raw_data_row contains the raw data sent by the backend which represents the raw data resulting from the query instead of converting it to a native GDScript type.
521+
## Note that the frontend does not check the validity of the data, so you have to check the data manually.
522+
## Sub-array data types are of type String if row_description.["format_code"] is 0 and of type PackedByteArray if 1.
517523
var raw_data_row := []
518524

519525
## This is usually a single word that identifies which SQL command was completed.
@@ -645,6 +651,7 @@ func reponce_parser(fragmented_answer: PackedByteArray):
645651

646652
var cursor := 0
647653
var row := []
654+
var raw_row := []
648655

649656
# Next, the following pair of fields appear for each column.
650657
for i in number_of_columns:
@@ -663,6 +670,7 @@ func reponce_parser(fragmented_answer: PackedByteArray):
663670
# The result.
664671
row.append(null)
665672

673+
raw_row.append(null)
666674
value_length = 0
667675
else:
668676
var value_data := response_buffer.slice(cursor + 11, cursor + 11 + value_length)
@@ -871,10 +879,6 @@ func reponce_parser(fragmented_answer: PackedByteArray):
871879
"TIMESTAMP":
872880
### TIMESTAMP ###
873881

874-
pass
875-
"DATE":
876-
### DATE ###
877-
878882
pass
879883
"INTERVAL":
880884
### INTERVAL ###
@@ -1083,11 +1087,17 @@ func reponce_parser(fragmented_answer: PackedByteArray):
10831087
_:
10841088
# The type returned is PackedByteArray.
10851089
row.append(value_data)
1090+
1091+
if postgresql_query_result_instance.row_description[i]["type_object_id"]: #/!\ A verif /!\
1092+
raw_row.append(value_data.get_string_from_utf8())
1093+
else:
1094+
raw_row.append(value_data)
10861095

10871096
cursor += value_length + 4
10881097

10891098
# The result.
10901099
postgresql_query_result_instance.data_row.append(row)
1100+
postgresql_query_result_instance.raw_data_row.append(raw_row)
10911101
'E':
10921102
### ErrorResponse ###
10931103

0 commit comments

Comments
 (0)