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

Hbpgsql problem insert empty date #234

Closed
marcoprodata opened this issue Mar 30, 2021 · 4 comments
Closed

Hbpgsql problem insert empty date #234

marcoprodata opened this issue Mar 30, 2021 · 4 comments

Comments

@marcoprodata
Copy link
Contributor

simple.txt

When insert empty date using fieldput return error:
ERROR: 22007: invalid input syntax for type date: " "

@alcz
Copy link
Contributor

alcz commented Mar 30, 2021

In case of hbpgsql contrib i think you should rather use SQL equivalent of "empty date" state, which is NIL/NULL.
If you want to indicate something else, i think PostgreSQL also has "infinity".
Try SELECT 'infinity'::timestamp, '-infinity'::timestamp.

hbpgsql patch proposals on how to handle such xBase constructs are possible too... should it be converted to NULL?

@marcoprodata
Copy link
Contributor Author

The problem is when use :fieldPut, i think the problem is in the ValueToString when type field type is date.

@alcz
Copy link
Contributor

alcz commented Mar 31, 2021

Consequently, PostgreSQL doesn't have anything that maps directly to xBase empty date, either:

  • don't insert empty date to SQL
  • request that you'd like to have hbpgsql ValueToString convert empty date to SQL NULL

Anyway i'll probably commit the latter while doing the sync of hbpgsql contrib NULL support changes from my repo and also Viktor's fork. This will take a while.

@marcoprodata
Copy link
Contributor Author

I Submit a PR to solve the trouble, please review

alcz added a commit that referenced this issue Mar 31, 2021
  * contrib/hbpgsql/postgres.c
    ! guard PQEXECPARAMS() wrapper from generating unrecoverable error
      on empty parameter array "hb_xgrab requested to allocate zero bytes"

  * contrib/hbpgsql/tpostgre.prg
    ! corrected buggy parameter order in TPQserver():Query()

    * make TPQQuery, TPQRow classes more aware of NIL to NULL conversions,
      added support for inserting and updating empty xBase date value
      should fix issue #234, oRow:FieldPut( <n>, NIL ) also looks good
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