Skip to content

fixes #7879 - config set schema command for postgresql#7892

Merged
matthiasblaesing merged 1 commit intoapache:masterfrom
wumpz:add-postresql-change-schema
Nov 4, 2024
Merged

fixes #7879 - config set schema command for postgresql#7892
matthiasblaesing merged 1 commit intoapache:masterfrom
wumpz:add-postresql-change-schema

Conversation

@wumpz
Copy link
Copy Markdown
Contributor

@wumpz wumpz commented Oct 21, 2024

Postgresql configuration does simply not contain the set default schema command.

This PR tries to include this.

The most fitting command seems to be set search_path.

@matthiasblaesing
Copy link
Copy Markdown
Contributor

Thanks for taking care, but this was not tested. I ran this PR against the current postgres docker container and it immediately blows up:

INFO [org.netbeans.modules.db.explorer.DatabaseConnection]: Unable to execute command:
set search_path "public"
ERROR: syntax error at or near ""public""
  Position: 17
org.netbeans.lib.ddl.DDLException: Unable to execute command:
set search_path "public"
ERROR: syntax error at or near ""public""
  Position: 17
	at org.netbeans.lib.ddl.impl.AbstractCommand.execute(AbstractCommand.java:204)
	at org.netbeans.modules.db.explorer.node.DDLHelper.setDefaultSchema(DDLHelper.java:50)
	at org.netbeans.modules.db.explorer.DatabaseConnection.setDefaultSchema(DatabaseConnection.java:651)
[catch] at org.netbeans.modules.db.explorer.DatabaseConnection.doConnect(DatabaseConnection.java:909)
	at org.netbeans.modules.db.explorer.DatabaseConnection.access$200(DatabaseConnection.java:78)
	at org.netbeans.modules.db.explorer.DatabaseConnection$3.run(DatabaseConnection.java:963)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1403)
	at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:287)
	at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2018)

This: https://www.postgresql.org/docs/current/ddl-schemas.html#DDL-SCHEMAS-PATH indicates, that you are looking for SET search_path TO.

@wumpz
Copy link
Copy Markdown
Contributor Author

wumpz commented Nov 1, 2024

What would be the right way to write a unit test for this?

You are right, my PR does not have the "to". I will change that.

@matthiasblaesing
Copy link
Copy Markdown
Contributor

What would be the right way to write a unit test for this?

Depends on what you want to validate the core problem would only have been visible with an integration test running against a real postgres DB. In this case, I would validate manually and be done with it. I spun up a minimal postgres DB using Docker (apart from the port this is a verbatim copy of the command suggested on docker hub):

docker run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -p 5432:5432 -d postgres

@wumpz
Copy link
Copy Markdown
Contributor Author

wumpz commented Nov 2, 2024

I tested this version within your simple docker variant. Now it's working as I expected it.

@matthiasblaesing
Copy link
Copy Markdown
Contributor

@wumpz looks good to me. Would you please squash the two commits into one. Summary and author information of the first entry look sane.

I'll target this to NB25. You can patch your installed netbeans by applying the modification to the file org/netbeans/lib/ddl/resources/dbspec.plist inside <nbroot>/ide/modules/ext/ddl.jar.

@mbien mbien added the enterprise [ci] enable enterprise job label Nov 2, 2024
@wumpz
Copy link
Copy Markdown
Contributor Author

wumpz commented Nov 2, 2024

Stupid question. I know the squash and merge option but how do I compress this as a PR provider?

@matthiasblaesing
Copy link
Copy Markdown
Contributor

@wumpz not a stupid question 😄

The first question would be "Why??": Github has a "Squash-and-Merge" Button. The problem is, that in contrast to git CLI, github tries to be clever on squash. git CLI uses the author information of the commits, github tries to interpolate author information from the public information of the account, github thinks is responsible for this. We had multiple cases where commits ended with mutilated author information: no email or githubs broken pseudo email, nickname instead of real name. The function is just not trustworthy.

The second question: PRs are just copies of your local branches. The idea is, that you do a local squash of your commits. Pushing this modified branch is normally prohibited by the git client as it is a destructive action. You need to tell the git client that you want to do it by doing a "forced" push.

Info about squashing: https://www.git-tower.com/learn/git/faq/git-squash, info about force pushing: https://git-scm.com/docs/git-push#Documentation/git-push.txt---force (it is just a flag when pushing)

@wumpz wumpz force-pushed the add-postresql-change-schema branch from f01286d to 1afa1a7 Compare November 3, 2024 14:23
@wumpz
Copy link
Copy Markdown
Contributor Author

wumpz commented Nov 3, 2024

So thx for the help. I corrected this PR. Interesting to now about this github squash problems. It took me a bit longer, since I ran into a problem that rebasing did not work on my repository version.

@mbien
Copy link
Copy Markdown
Member

mbien commented Nov 3, 2024

https://github.com/apache/netbeans/pull/7892.patch patch looks good now -> squash worked

@matthiasblaesing matthiasblaesing added this to the NB25 milestone Nov 4, 2024
@matthiasblaesing matthiasblaesing merged commit ba8326b into apache:master Nov 4, 2024
@matthiasblaesing
Copy link
Copy Markdown
Contributor

@wumpz thanks for taking care of this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enterprise [ci] enable enterprise job

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants