Skip to content

Commit a4e51a1

Browse files
committed
feat: resolve a few issues with tests and integration with tooling
1 parent 855433c commit a4e51a1

File tree

7 files changed

+107
-30
lines changed

7 files changed

+107
-30
lines changed

nix/checks.nix

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
psql_15 = self'.packages."psql_15/bin";
1414
psql_17 = self'.packages."psql_17/bin";
1515
psql_orioledb-17 = self'.packages."psql_orioledb-17/bin";
16-
pgroonga = self'.packages."psql_15/exts/pgroonga";
1716
inherit (self.supabase) defaults;
1817
};
1918
in
@@ -68,9 +67,36 @@
6867
'';
6968
};
7069

70+
# Get the major version for filtering
71+
majorVersion =
72+
let
73+
version = builtins.trace "pgpkg.version is: ${pgpkg.version}" pgpkg.version;
74+
isOrioledbMatch = builtins.match "^17_[0-9]+$" version != null;
75+
isSeventeenMatch = builtins.match "^17[.][0-9]+$" version != null;
76+
result =
77+
if isOrioledbMatch then
78+
"orioledb-17"
79+
else if isSeventeenMatch then
80+
"17"
81+
else
82+
"15";
83+
in
84+
builtins.trace "Major version result: ${result}" result;
85+
86+
# Select the appropriate pgroonga package for this PostgreSQL version
87+
pgroonga = self'.packages."psql_${majorVersion}/exts/pgroonga-all";
88+
89+
pgPort =
90+
if (majorVersion == "17") then
91+
"5535"
92+
else if (majorVersion == "15") then
93+
"5536"
94+
else
95+
"5537";
96+
7197
# Use the shared setup but with a test-specific name
7298
start-postgres-server-bin = pkgs-lib.makePostgresDevSetup {
73-
inherit pkgs;
99+
inherit pkgs pgroonga;
74100
name = "start-postgres-server-test";
75101
extraSubstitutions = {
76102
PGSODIUM_GETKEY = "${getkey-script}/bin/pgsodium-getkey";
@@ -116,33 +142,9 @@
116142
in
117143
pkgs.lib.filterAttrs (name: _: isValidFile name) files;
118144

119-
# Get the major version for filtering
120-
majorVersion =
121-
let
122-
version = builtins.trace "pgpkg.version is: ${pgpkg.version}" pgpkg.version;
123-
isOrioledbMatch = builtins.match "^17_[0-9]+$" version != null;
124-
isSeventeenMatch = builtins.match "^17[.][0-9]+$" version != null;
125-
result =
126-
if isOrioledbMatch then
127-
"orioledb-17"
128-
else if isSeventeenMatch then
129-
"17"
130-
else
131-
"15";
132-
in
133-
builtins.trace "Major version result: ${result}" result; # Trace the result # For "15.8"
134-
135145
# Filter SQL test files
136146
filteredSqlTests = filterTestFiles majorVersion ./tests/sql;
137147

138-
pgPort =
139-
if (majorVersion == "17") then
140-
"5535"
141-
else if (majorVersion == "15") then
142-
"5536"
143-
else
144-
"5537";
145-
146148
# Convert filtered tests to a sorted list of basenames (without extension)
147149
testList = pkgs.lib.mapAttrsToList (
148150
name: _: builtins.substring 0 (pkgs.lib.stringLength name - 4) name

nix/ext/postgis.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
}:
2020

2121
let
22-
sfcgal = callPackage ./sfcgal/sfcgal.nix { };
22+
sfcgal = callPackage ../packages/sfcgal.nix { };
2323
gdal = callPackage ./gdal.nix { inherit postgresql; };
2424
pname = "postgis";
2525

nix/ext/tests/pgroonga.nix

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ self.inputs.nixpkgs.lib.nixos.runTest {
107107
requires = [ "postgresql-migrate.service" ];
108108
};
109109
};
110-
111110
};
112111
testScript =
113112
{ nodes, ... }:

nix/packages/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
psql_15 = self'.packages."psql_15/bin";
2424
psql_17 = self'.packages."psql_17/bin";
2525
psql_orioledb-17 = self'.packages."psql_orioledb-17/bin";
26-
pgroonga = self'.packages."psql_15/exts/pgroonga";
2726
inherit (self.supabase) defaults;
2827
};
2928
in
@@ -60,6 +59,7 @@
6059
start-server = pkgs-lib.makePostgresDevSetup {
6160
inherit pkgs;
6261
name = "start-postgres-server";
62+
pgroonga = self'.packages."psql_${activeVersion}/exts/pgroonga-all";
6363
};
6464
switch-ext-version = pkgs.callPackage ./switch-ext-version.nix {
6565
inherit (self'.packages) overlayfs-on-package;

nix/packages/lib.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
defaults,
66
supabase-groonga,
77
system,
8-
pgroonga,
98
}:
109
{
1110
makePostgresDevSetup =
1211
{
1312
pkgs,
1413
name,
14+
pgroonga,
1515
extraSubstitutions ? { },
1616
}:
1717
let

nix/tests/expected/pgroonga.out

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
create schema v;
2+
create table v.roon(
3+
id serial primary key,
4+
content text
5+
);
6+
with tokenizers as (
7+
select
8+
x
9+
from
10+
jsonb_array_elements(
11+
(select pgroonga_command('tokenizer_list'))::jsonb
12+
) x(val)
13+
limit
14+
1
15+
offset
16+
1 -- first record is unrelated and not stable
17+
)
18+
select
19+
t.x::jsonb ->> 'name'
20+
from
21+
jsonb_array_elements((select * from tokenizers)) t(x)
22+
order by
23+
t.x::jsonb ->> 'name';
24+
?column?
25+
---------------------------------------------
26+
TokenBigram
27+
TokenBigramIgnoreBlank
28+
TokenBigramIgnoreBlankSplitSymbol
29+
TokenBigramIgnoreBlankSplitSymbolAlpha
30+
TokenBigramIgnoreBlankSplitSymbolAlphaDigit
31+
TokenBigramSplitSymbol
32+
TokenBigramSplitSymbolAlpha
33+
TokenBigramSplitSymbolAlphaDigit
34+
TokenDelimit
35+
TokenDelimitNull
36+
TokenDocumentVectorBM25
37+
TokenDocumentVectorTFIDF
38+
TokenMecab
39+
TokenNgram
40+
TokenPattern
41+
TokenRegexp
42+
TokenTable
43+
TokenTrigram
44+
TokenUnigram
45+
(19 rows)
46+
47+
insert into v.roon (content)
48+
values
49+
('Hello World'),
50+
('PostgreSQL with PGroonga is a thing'),
51+
('This is a full-text search test'),
52+
('PGroonga supports various languages');
53+
-- Create default index
54+
create index pgroonga_index on v.roon using pgroonga (content);
55+
-- Create mecab tokenizer index since we had a bug with this one once
56+
create index pgroonga_index_mecab on v.roon using pgroonga (content) with (tokenizer='TokenMecab');
57+
-- Run some queries to test the index
58+
select * from v.roon where content &@~ 'Hello';
59+
id | content
60+
----+-------------
61+
1 | Hello World
62+
(1 row)
63+
64+
select * from v.roon where content &@~ 'powerful';
65+
id | content
66+
----+---------
67+
(0 rows)
68+
69+
select * from v.roon where content &@~ 'supports';
70+
id | content
71+
----+-------------------------------------
72+
4 | PGroonga supports various languages
73+
(1 row)
74+
75+
drop schema v cascade;
76+
NOTICE: drop cascades to table v.roon
File renamed without changes.

0 commit comments

Comments
 (0)