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

Reading text array from postGRESQL #55

Open
naturalmechanics opened this issue Feb 7, 2025 · 4 comments
Open

Reading text array from postGRESQL #55

naturalmechanics opened this issue Feb 7, 2025 · 4 comments

Comments

@naturalmechanics
Copy link

My postGRESql contains some data as a text array column.

Column name is overview.

If I try:

auto r = result[0];
// check r["overview"] not null works
auto v = r["overview"].toString;

I get this error:

Please report if you came across this error! lbound==2.

Help please.

@naturalmechanics naturalmechanics changed the title Reading text array from postGERswl Reading text array from postGRESQL Feb 7, 2025
@denizzzka
Copy link
Owner

denizzzka commented Feb 7, 2025

Wow, that's interesting! It was issued from: https://github.com/denizzzka/dpq2/blob/6d45b66d3504bce96d09f71a70878a64e7acb1e2/src/dpq2/result.d#L557

Please can you make SQL request in the form:

select overview::text

and get text representation of this cell directly from the server? So that I can understand what exactly dimensions format this overview array has?

@denizzzka
Copy link
Owner

@naturalmechanics as quck and dirty fix try to comment out this check: https://github.com/denizzzka/dpq2/blob/6d45b66d3504bce96d09f71a70878a64e7acb1e2/src/dpq2/result.d#L558

I think it is not needed at all - this field is, probably, only used internally by the server.

@denizzzka
Copy link
Owner

denizzzka commented Feb 7, 2025

It has something to do with PG slices, I think: https://www.postgresql.org/docs/current/arrays.html#ARRAYS-IO

By default, the lower bound index value of an array's dimensions is set to one. To represent arrays with other lower bounds, the array subscript ranges can be specified explicitly before writing the array contents. This decoration consists of square brackets ([]) around each array dimension's lower and upper bounds, with a colon (:) delimiter character in between. The array dimension decoration is followed by an equal sign (=)

@naturalmechanics
Copy link
Author

Wow, that's interesting! It was issued from: https://github.com/denizzzka/dpq2/blob/6d45b66d3504bce96d09f71a70878a64e7acb1e2/src/dpq2/result.d#L557

Please can you make SQL request in the form:

select overview::text

and get text representation of this cell directly from the server? So that I can understand what exactly dimensions format this overview array has?

I will do that on monday back in office. Sorry for the delay

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants