Skip to content

Commit ce02d7d

Browse files
test: eftdb: generator: update with edition checks
The checks will now account for editions by checking the current version.
1 parent eb726c0 commit ce02d7d

File tree

1 file changed

+52
-10
lines changed

1 file changed

+52
-10
lines changed

tests/Eftdb.Tests/Generators/HypertableOperationGeneratorComprehensiveTests.cs

Lines changed: 52 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ public void DesignTime_Create_WithRangeDimension_GeneratesCorrectCode()
6161
};
6262

6363
string expected = @".Sql(@""
64-
SELECT create_hypertable('public.""""events""""', 'event_time');
65-
SELECT set_chunk_time_interval('public.""""events""""', INTERVAL '1 day');
64+
SELECT create_hypertable('public.""""events""""', 'event_time', chunk_time_interval => INTERVAL '1 day');
6665
SELECT add_dimension('public.""""events""""', by_range('received_time', INTERVAL '7 days'));
6766
"")";
6867

@@ -115,8 +114,7 @@ public void DesignTime_Create_WithChunkTimeIntervalAsMicroseconds_GeneratesCorre
115114
};
116115

117116
string expected = @".Sql(@""
118-
SELECT create_hypertable('public.""""high_freq_data""""', 'ts');
119-
SELECT set_chunk_time_interval('public.""""high_freq_data""""', 86400000000::bigint);
117+
SELECT create_hypertable('public.""""high_freq_data""""', 'ts', chunk_time_interval => 86400000000::bigint);
120118
"")";
121119

122120
// Act
@@ -140,7 +138,18 @@ public void DesignTime_Create_CompressionWithoutChunkSkipping_GeneratesCorrectCo
140138

141139
string expected = @".Sql(@""
142140
SELECT create_hypertable('public.""""compressed_data""""', 'time');
143-
ALTER TABLE """"public"""".""""compressed_data"""" SET (timescaledb.compress = true);
141+
DO $$
142+
DECLARE
143+
license TEXT;
144+
BEGIN
145+
license := current_setting('timescaledb.license', true);
146+
147+
IF license IS NULL OR license != 'apache' THEN
148+
ALTER TABLE """"public"""".""""compressed_data"""" SET (timescaledb.compress = true);
149+
ELSE
150+
RAISE WARNING 'Skipping Community Edition features (compression, chunk skipping) - not available in Enterprise Edition';
151+
END IF;
152+
END $$;
144153
"")";
145154

146155
// Act
@@ -415,7 +424,18 @@ public void DesignTime_Alter_DisablingCompression_GeneratesCorrectCode()
415424
};
416425

417426
string expected = @".Sql(@""
418-
ALTER TABLE """"public"""".""""decompress"""" SET (timescaledb.compress = false);
427+
DO $$
428+
DECLARE
429+
license TEXT;
430+
BEGIN
431+
license := current_setting('timescaledb.license', true);
432+
433+
IF license IS NULL OR license != 'apache' THEN
434+
ALTER TABLE """"public"""".""""decompress"""" SET (timescaledb.compress = false);
435+
ELSE
436+
RAISE WARNING 'Skipping Community Edition features (compression, chunk skipping) - not available in Enterprise Edition';
437+
END IF;
438+
END $$;
419439
"")";
420440

421441
// Act
@@ -438,9 +458,20 @@ public void DesignTime_Alter_AddingChunkSkipColumn_GeneratesCorrectSequence()
438458
};
439459

440460
string expected = @".Sql(@""
441-
SET timescaledb.enable_chunk_skipping = 'ON';
442-
SELECT enable_chunk_skipping('public.""""add_skip""""', 'col2');
443-
SELECT enable_chunk_skipping('public.""""add_skip""""', 'col3');
461+
DO $$
462+
DECLARE
463+
license TEXT;
464+
BEGIN
465+
license := current_setting('timescaledb.license', true);
466+
467+
IF license IS NULL OR license != 'apache' THEN
468+
SET timescaledb.enable_chunk_skipping = 'ON';
469+
SELECT enable_chunk_skipping('public.""""add_skip""""', 'col2');
470+
SELECT enable_chunk_skipping('public.""""add_skip""""', 'col3');
471+
ELSE
472+
RAISE WARNING 'Skipping Community Edition features (compression, chunk skipping) - not available in Enterprise Edition';
473+
END IF;
474+
END $$;
444475
"")";
445476

446477
// Act
@@ -463,7 +494,18 @@ public void DesignTime_Alter_RemovingChunkSkipColumn_GeneratesDisableCommands()
463494
};
464495

465496
string expected = @".Sql(@""
466-
SELECT disable_chunk_skipping('public.""""remove_skip""""', 'remove_this');
497+
DO $$
498+
DECLARE
499+
license TEXT;
500+
BEGIN
501+
license := current_setting('timescaledb.license', true);
502+
503+
IF license IS NULL OR license != 'apache' THEN
504+
SELECT disable_chunk_skipping('public.""""remove_skip""""', 'remove_this');
505+
ELSE
506+
RAISE WARNING 'Skipping Community Edition features (compression, chunk skipping) - not available in Enterprise Edition';
507+
END IF;
508+
END $$;
467509
"")";
468510

469511
// Act

0 commit comments

Comments
 (0)