Comments (2)
@pematt The original problem is fixed. However, the generated diff still has a semantic problem that I still need to figure out how to solve.
After applying the patch the generate code was:
-- [ Dropped objects ] --
ALTER TABLE test.test DETACH PARTITION test.test_2024;
-- ddl-end --
ALTER TABLE test.test DETACH PARTITION test.test_2025;
-- ddl-end --
-- [ Created objects ] --
ALTER TABLE test.test ADD COLUMN new_column smallint;
-- ddl-end --
ALTER TABLE test.test ATTACH PARTITION test.test_2024 FOR VALUES FROM ('2024-01-01') TO ('2025-01-01');
-- ddl-end --
ALTER TABLE test.test ATTACH PARTITION test.test_2025 FOR VALUES FROM ('2025-01-01') TO ('2026-01-01');
-- ddl-end --
But if you run the diff above from pgModeler it'll break on the first ALTER TABLE ... ATTACH
that's because since the partitions were detached in the first lines of the script we have to add the new columns on all partitions which is not happening according to the diff code.
The lines where ATTACH
and DETACH
appear are false-positive codes because they are only generated when the partitioning bounding expressions change. It took me a while to figure out what was happening... but pgModeler compares the partitioning bounding expression from the original model and the one imported by the diff process.
It turns out that PostgreSQL converts FOR VALUES FROM ('2025-01-01') TO ('2026-01-01');
to FOR VALUES FROM ('2025-01-01 00:00:00-03') TO ('2026-01-01 00:00:00-03');
. Semantically, they are all the same, but for pgModeler not, and that is causing pgModeler to create the code to detach and (re)attach the partitions. The workaround for this issue is to add the hour (and eventually the timezone) to the partitions' bounding expressions in your database model so the mentioned code stops being generated. Your example, unfortunately, hits one of the limitations of pgModeler: the semantical comparison which isn't available at the moment! :(
from pgmodeler.
Ok I will do that. Thank you very much for the detailed explanation how to solve it!
from pgmodeler.
Related Issues (20)
- Can't open model.sdbm after saving model.dbm as split model HOT 6
- False positive diff on default value function name within quotes
- Develop CockroachDB compatibility HOT 6
- Error while saving since updating to 1.1.0 HOT 1
- Please add possibility to use custom data types HOT 2
- "Converting" a relationship shouldn't lose the relationships layer information.
- Diff breaks with error if custom collation exists at database side (~pg16). HOT 1
- Crash while trying to delete an table object
- After swapping IDs pgmodeler crashed while saving; .sdbm unrecoverable HOT 3
- Importing views with LOCAL CHECK option does not seem to retain the "LOCAL CHECK" syntax HOT 2
- "Import objects to the working model" should not reset table positions HOT 7
- 1.1.0 policy must have new line or parse will get error, after using space workaround, fix model cannot create file HOT 2
- Materialized View recreation during Fix Model adds extra semi-colon (Upgrading from 1.0.5 to 1.1.1) HOT 2
- When Exporting SQL, Allow User to Split by creating 1 SQL File for each Specific Database Object Types
- Multiple build errors in `src/sampleplugin.h`: `Undefined interface` & `expected class-name before ‘,’ token`
- FileDirectoryNotAccessed: pgmodeler is unable to locate/load any needed resource file
- Bad constraint comment SQL generated. HOT 3
- How to use on Debian 12? HOT 17
- Table and attribute display bug HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pgmodeler.