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

False positive diff on default value function name within quotes #1851

Open
pematt opened this issue Feb 15, 2024 · 1 comment
Open

False positive diff on default value function name within quotes #1851

pematt opened this issue Feb 15, 2024 · 1 comment

Comments

@pematt
Copy link

pematt commented Feb 15, 2024

Bug description
The diff generates a false positive on a column with a default value that is an expression which is a function with a quoted name. Possibly this is limited to quoted schema names.

How to reproduce
test3.dbm.zip

  1. Open the attached test3.dbm model.
  2. Install it into an empty database.
  3. Generate another diff.

The diff generates a false positive on the id column which as a default value of "test2"."getNextId"():

-- Diff code generated with pgModeler (PostgreSQL Database Modeler)
-- pgModeler version: 1.1.0
-- Diff date: 2024-02-15 13:07:31
-- Source model: new_database
-- Database: mpdb
-- PostgreSQL version: 16.0

-- [ Diff summary ]
-- Dropped objects: 0
-- Created objects: 0
-- Changed objects: 1

SET check_function_bodies = false;
-- ddl-end --

SET search_path=public,pg_catalog,test,test2;
-- ddl-end --


-- [ Changed objects ] --
ALTER TABLE test.test ALTER COLUMN id SET DEFAULT "test2"."getNextId"();
-- ddl-end --

column_properties

Expected behavior
Since the model has not been changed the diff should yield no result.

Info about your desktop
OS: Linux Mint
Version: 21.1
Window manager: Cinnamon
pgModeler version: 1.1.0
Qt version: 6.2.4

@rkhaotix
Copy link
Member

Hi @pematt

Sorry for the delay in response.

There's no need to double-quote the test2 schema name in the default value of the column, that's why you're having that result.

If you import the model after exporting it, you'll see that the default value of the column will be test2."getNextId()". That's because PostgreSQL completely ignores the double quotes in test2. I agree that pgModeler should not bother with the double quotes in default expressions, but this field isn't used only for function calls and may contain a string that the double quotes are necessary and can change the semantics of the value. That's why pgModeler doesn't ignore the double quotes in the diff process.

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