Skip to content

Commit c12d5c0

Browse files
test: generator: update test with new edition changes
1 parent 4c05440 commit c12d5c0

File tree

1 file changed

+68
-14
lines changed

1 file changed

+68
-14
lines changed

CmdScale.EntityFrameworkCore.TimescaleDB.Tests/Generators/HypertableOperationGeneratorTests.cs

Lines changed: 68 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,22 @@ public void Generate_Create_with_all_options_generates_comprehensive_sql()
6464
};
6565

6666
string expected = @".Sql(@""
67-
SELECT create_hypertable('custom_schema.""""FullTable""""', 'EventTime');
68-
SELECT set_chunk_time_interval('custom_schema.""""FullTable""""', INTERVAL '1 day');
69-
ALTER TABLE """"custom_schema"""".""""FullTable"""" SET (timescaledb.compress = true);
70-
SET timescaledb.enable_chunk_skipping = 'ON';
71-
SELECT enable_chunk_skipping('custom_schema.""""FullTable""""', 'DeviceId');
67+
SELECT create_hypertable('custom_schema.""""FullTable""""', 'EventTime', chunk_time_interval => INTERVAL '1 day');
7268
SELECT add_dimension('custom_schema.""""FullTable""""', by_hash('LocationId', 4));
69+
DO $$
70+
DECLARE
71+
license TEXT;
72+
BEGIN
73+
license := current_setting('timescaledb.license', true);
74+
75+
IF license IS NULL OR license != 'apache' THEN
76+
ALTER TABLE """"custom_schema"""".""""FullTable"""" SET (timescaledb.compress = true);
77+
SET timescaledb.enable_chunk_skipping = 'ON';
78+
SELECT enable_chunk_skipping('custom_schema.""""FullTable""""', 'DeviceId');
79+
ELSE
80+
RAISE WARNING 'Skipping Community Edition features (compression, chunk skipping) - not available in Enterprise Edition';
81+
END IF;
82+
END $$;
7383
"")";
7484

7585
// Act
@@ -94,9 +104,20 @@ public void Generate_Alter_WhenAddingChunkSkippingToUncompressedTable_ShouldAlso
94104
};
95105

96106
string expected = @".Sql(@""
97-
ALTER TABLE """"custom_schema"""".""""Metrics"""" SET (timescaledb.compress = true);
98-
SET timescaledb.enable_chunk_skipping = 'ON';
99-
SELECT enable_chunk_skipping('custom_schema.""""Metrics""""', 'device_id');
107+
DO $$
108+
DECLARE
109+
license TEXT;
110+
BEGIN
111+
license := current_setting('timescaledb.license', true);
112+
113+
IF license IS NULL OR license != 'apache' THEN
114+
ALTER TABLE """"custom_schema"""".""""Metrics"""" SET (timescaledb.compress = true);
115+
SET timescaledb.enable_chunk_skipping = 'ON';
116+
SELECT enable_chunk_skipping('custom_schema.""""Metrics""""', 'device_id');
117+
ELSE
118+
RAISE WARNING 'Skipping Community Edition features (compression, chunk skipping) - not available in Enterprise Edition';
119+
END IF;
120+
END $$;
100121
"")";
101122

102123
// Act
@@ -121,7 +142,18 @@ public void Generate_Alter_when_changing_compression_generates_correct_sql()
121142
};
122143

123144
string expected = @".Sql(@""
124-
ALTER TABLE """"public"""".""""SensorData"""" SET (timescaledb.compress = true);
145+
DO $$
146+
DECLARE
147+
license TEXT;
148+
BEGIN
149+
license := current_setting('timescaledb.license', true);
150+
151+
IF license IS NULL OR license != 'apache' THEN
152+
ALTER TABLE """"public"""".""""SensorData"""" SET (timescaledb.compress = true);
153+
ELSE
154+
RAISE WARNING 'Skipping Community Edition features (compression, chunk skipping) - not available in Enterprise Edition';
155+
END IF;
156+
END $$;
125157
"")";
126158

127159
// Act
@@ -144,9 +176,20 @@ public void Generate_Alter_when_adding_and_removing_skip_columns_generates_corre
144176
};
145177

146178
string expected = @".Sql(@""
147-
SET timescaledb.enable_chunk_skipping = 'ON';
148-
SELECT enable_chunk_skipping('metrics_schema.""""Metrics""""', 'service');
149-
SELECT disable_chunk_skipping('metrics_schema.""""Metrics""""', 'region');
179+
DO $$
180+
DECLARE
181+
license TEXT;
182+
BEGIN
183+
license := current_setting('timescaledb.license', true);
184+
185+
IF license IS NULL OR license != 'apache' THEN
186+
SET timescaledb.enable_chunk_skipping = 'ON';
187+
SELECT enable_chunk_skipping('metrics_schema.""""Metrics""""', 'service');
188+
SELECT disable_chunk_skipping('metrics_schema.""""Metrics""""', 'region');
189+
ELSE
190+
RAISE WARNING 'Skipping Community Edition features (compression, chunk skipping) - not available in Enterprise Edition';
191+
END IF;
192+
END $$;
150193
"")";
151194

152195
// Act
@@ -193,8 +236,19 @@ public void Generate_Alter_WhenRemovingLastChunkSkipColumn_ShouldDisableCompress
193236
ChunkSkipColumns = []
194237
};
195238
string expected = @".Sql(@""
196-
ALTER TABLE """"public"""".""""Logs"""" SET (timescaledb.compress = false);
197-
SELECT disable_chunk_skipping('public.""""Logs""""', 'trace_id');
239+
DO $$
240+
DECLARE
241+
license TEXT;
242+
BEGIN
243+
license := current_setting('timescaledb.license', true);
244+
245+
IF license IS NULL OR license != 'apache' THEN
246+
ALTER TABLE """"public"""".""""Logs"""" SET (timescaledb.compress = false);
247+
SELECT disable_chunk_skipping('public.""""Logs""""', 'trace_id');
248+
ELSE
249+
RAISE WARNING 'Skipping Community Edition features (compression, chunk skipping) - not available in Enterprise Edition';
250+
END IF;
251+
END $$;
198252
"")";
199253

200254
// Act

0 commit comments

Comments
 (0)