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

postgres: current_schema: converting NULL to string is unsupported (empty search_path is NULL) #696

Closed
disq opened this issue Feb 3, 2022 · 4 comments

Comments

@disq
Copy link

disq commented Feb 3, 2022

Describe the Bug
If the search_path is empty, CURRENT_SCHEMA() returns NULL but the reader tries to read a string so it fails with:

*database.Error: sql: Scan error on column index 0, name "current_schema": converting NULL to string is unsupported in line 0: SELECT CURRENT_SCHEMA()

Steps to Reproduce
Steps to reproduce the behavior:

  1. Give it a DSN with empty search path
  2. Run migrate
  3. It will fail badly

Expected Behavior
Fail better returning ErrNoSchema, in

return nil, ErrNoSchema

Migrate Version
v4.15.0

Loaded Database Drivers
postgres

Go Version
go version go1.17.2 darwin/arm64

Additional context
Should just scan into *string allowing nulls to work.

cq=# set search_path='';
SET
cq=# SELECT CURRENT_SCHEMA();
 current_schema
----------------

(1 row)

cq=# SELECT CURRENT_SCHEMA() is null;
 ?column?
----------
 t
(1 row)
@disq
Copy link
Author

disq commented Feb 3, 2022

Same as #692 which was closed

@itissourav
Copy link

Hi @disq I am stucked in this issue..What may be the causes for this issue? Cant find any solution..

soyayaos added a commit to soyayaos/migrate that referenced this issue Apr 6, 2023
@soyayaos
Copy link
Contributor

soyayaos commented Apr 6, 2023

fixed in #914

dhui added a commit that referenced this issue Apr 7, 2023
fix: postgresql search_path can be empty (#696)
@dhui
Copy link
Member

dhui commented Apr 7, 2023

Thanks @soyayaos for the fix! Closing this issue for now. Please reopen this if it's still not fixed

@dhui dhui closed this as completed Apr 7, 2023
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

4 participants