brianc / node-pg-types

Type parsing for node-postgres
268 stars 55 forks source link

Strange array representation before parsing #75

Closed btd closed 5 years ago

btd commented 5 years ago

Hi there.

I have several arrray of types _int4 and _int8. When updating type parser for _int8 i noticed that db returns for this column such repesentation: [0:3]={2,4,3,1}. Have you seen something like this?

I am using AWS RDS 10.4

btd commented 5 years ago

I found this comment in pgjdbc driver:

      // Starting with 8.0 non-standard (beginning index
      // isn't 1) bounds the dimensions are returned in the
      // data formatted like so "[0:3]={0,1,2,3,4}".
      // Older versions simply do not return the bounds.
      //
      // Right now we ignore these bounds, but we could
      // consider allowing these index values to be used
      // even though the JDBC spec says 1 is the first
      // index. I'm not sure what a client would like
      // to see, so we just retain the old behavior.
charmander commented 5 years ago

See https://github.com/bendrucker/postgres-array/issues/2.

btd commented 5 years ago

@charmander thanks. I missed this issue. But anyway i prepared PR for postgres-array. It works fine for my workload

bendrucker commented 5 years ago

Hi, I think we've fully discussed this issue in bendrucker/postgres-array#2. I'll leave comments on your PR. I'm glad it works for you but I don't think changing the default behavior is something we'll accept given my existing objections in the issue.

bendrucker commented 5 years ago

Good find on pgjbdc:

Right now we ignore these bounds, but we could consider allowing these index values to be used... I'm not sure what a client would like to see, so we just retain the old behavior.

That says it all to me. It's ambiguous, they already did it, and so now it stays. If you come from pgjbdc to any other client without this same behavior, your code breaks. If pgjbdc didn't make an assumption for you in the first place, you'd discover the mistake in your query/data right away and fix it.