-
Notifications
You must be signed in to change notification settings - Fork 30
fix: col default expression #93
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "name": "issue_91_default_expr", | ||
| "description": "Test case for default expression with NOT NULL dumping (GitHub issue #91)", | ||
| "source": "https://github.com/pgschema/pgschema/issues/91", | ||
| "notes": [ | ||
| "Tests that complex default expressions with NOT NULL constraints are correctly formatted", | ||
| "Bug: Missing closing parenthesis when default expression contains parentheses and column has NOT NULL", | ||
| "Example: DEFAULT (now() AT TIME ZONE 'utc') NOT NULL should not become DEFAULT (now() AT TIME ZONE 'utc' NOT NULL" | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| -- | ||
| -- PostgreSQL database dump | ||
| -- | ||
|
|
||
| -- Dumped from database version 17.5 (Debian 17.5-1.pgdg120+1) | ||
| -- Dumped by pg_dump version 17.5 (Homebrew) | ||
|
|
||
| SET statement_timeout = 0; | ||
| SET lock_timeout = 0; | ||
| SET idle_in_transaction_session_timeout = 0; | ||
| SET transaction_timeout = 0; | ||
| SET client_encoding = 'UTF8'; | ||
| SET standard_conforming_strings = on; | ||
| SELECT pg_catalog.set_config('search_path', '', false); | ||
| SET check_function_bodies = false; | ||
| SET xmloption = content; | ||
| SET client_min_messages = warning; | ||
| SET row_security = off; | ||
|
|
||
| SET default_tablespace = ''; | ||
|
|
||
| SET default_table_access_method = heap; | ||
|
|
||
| -- | ||
| -- Name: some_table; Type: TABLE; Schema: public; Owner: - | ||
| -- | ||
|
|
||
| CREATE TABLE public.some_table ( | ||
| id integer NOT NULL, | ||
| created_at timestamp without time zone DEFAULT (now() AT TIME ZONE 'utc'::text) NOT NULL | ||
| ); | ||
|
|
||
|
|
||
| -- | ||
| -- Name: some_table_id_seq; Type: SEQUENCE; Schema: public; Owner: - | ||
| -- | ||
|
|
||
| ALTER TABLE public.some_table ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY ( | ||
| SEQUENCE NAME public.some_table_id_seq | ||
| START WITH 1 | ||
| INCREMENT BY 1 | ||
| NO MINVALUE | ||
| NO MAXVALUE | ||
| CACHE 1 | ||
| ); | ||
|
|
||
|
|
||
| -- | ||
| -- Name: some_table some_table_pkey; Type: CONSTRAINT; Schema: public; Owner: - | ||
| -- | ||
|
|
||
| ALTER TABLE ONLY public.some_table | ||
| ADD CONSTRAINT some_table_pkey PRIMARY KEY (id); | ||
|
|
||
|
|
||
| -- | ||
| -- PostgreSQL database dump complete | ||
| -- | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| -- | ||
| -- pgschema database dump | ||
| -- | ||
|
|
||
| -- Dumped from database version PostgreSQL 17.5 | ||
| -- Dumped by pgschema version 1.4.0 | ||
|
|
||
|
|
||
| -- | ||
| -- Name: some_table; Type: TABLE; Schema: -; Owner: - | ||
| -- | ||
|
|
||
| CREATE TABLE IF NOT EXISTS some_table ( | ||
| id integer GENERATED BY DEFAULT AS IDENTITY, | ||
| created_at timestamp DEFAULT (now() AT TIME ZONE 'utc') NOT NULL, | ||
| CONSTRAINT some_table_pkey PRIMARY KEY (id) | ||
| ); | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| -- | ||
| -- Test case for GitHub issue #91: Default expression with NOT NULL dumping | ||
| -- | ||
| -- This test case reproduces a bug where column default expressions containing | ||
| -- parentheses combined with NOT NULL constraints are formatted incorrectly. | ||
| -- | ||
| -- The issue occurs when: | ||
| -- 1. A column has a default expression wrapped in parentheses | ||
| -- 2. The default expression contains complex SQL like `now() AT TIME ZONE 'utc'` | ||
| -- 3. The column also has a NOT NULL constraint | ||
| -- | ||
| -- Original bug: DEFAULT (now() AT TIME ZONE 'utc') NOT NULL | ||
| -- Gets corrupted to: DEFAULT (now() AT TIME ZONE 'utc' NOT NULL | ||
| -- (Missing closing parenthesis before NOT NULL!) | ||
| -- | ||
|
|
||
| -- | ||
| -- Test table with complex default expressions | ||
| -- | ||
| CREATE TABLE some_table ( | ||
| id serial primary key, | ||
| created_at timestamp without time zone default (now() at time zone 'utc') not null | ||
| ); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.