@@ -6,10 +6,49 @@ import {buildTestsRunner} from '../runner';
66import { PsqlQueryBuilder } from '../../../classes' ;
77import { expect } from '@loopback/testlab' ;
88import { testModelList , testModelListWithIdentifier } from '../..' ;
9+ import { AnyObject } from '@loopback/repository' ;
910
1011describe ( 'PostgreSQL QueryBuilder' , ( ) => {
1112 const queryPart =
1213 " from public.TestSearchedCustom where to_tsvector(public.f_concat_ws(' ', about, identifier)) @@ to_tsquery($1))" ;
14+
15+ describe ( '_formatAndSanitize' , ( ) => {
16+ it ( 'should preserve dots in search terms' , ( ) => {
17+ const builder = new PsqlQueryBuilder ( { match : 'Deal 10.1' } ) ;
18+ const result = ( builder as AnyObject ) . _formatAndSanitize ( 'Deal 10.1' ) ;
19+ expect ( result ) . to . equal ( 'Deal:*<->10.1:*' ) ;
20+ } ) ;
21+
22+ it ( 'should handle project names with dots' , ( ) => {
23+ const builder = new PsqlQueryBuilder ( { match : 'test' } ) ;
24+ const result = ( builder as AnyObject ) . _formatAndSanitize ( 'testlift.QA' ) ;
25+ expect ( result ) . to . equal ( 'testlift.QA:*' ) ;
26+ } ) ;
27+
28+ it ( 'should handle multiple dots in different positions' , ( ) => {
29+ const builder = new PsqlQueryBuilder ( { match : 'test' } ) ;
30+ const result = ( builder as AnyObject ) . _formatAndSanitize (
31+ 'Project.Alpha.Beta' ,
32+ ) ;
33+ expect ( result ) . to . equal ( 'Project.Alpha.Beta:*' ) ;
34+ } ) ;
35+
36+ it ( 'should handle mix of dots and special characters' , ( ) => {
37+ const builder = new PsqlQueryBuilder ( { match : 'test' } ) ;
38+ const result = ( builder as AnyObject ) . _formatAndSanitize (
39+ 'Deal.10 & Test.1.5' ,
40+ ) ;
41+ expect ( result ) . to . equal ( 'Deal.10:*<->Test.1.5:*' ) ;
42+ } ) ;
43+
44+ it ( 'should handle complex search with dots and spaces' , ( ) => {
45+ const builder = new PsqlQueryBuilder ( { match : 'test' } ) ;
46+ const result = ( builder as AnyObject ) . _formatAndSanitize (
47+ 'Version 2.5 (Release)' ,
48+ ) ;
49+ expect ( result ) . to . equal ( 'Version:*<->2.5:*<->Release:*' ) ;
50+ } ) ;
51+ } ) ;
1352 describe (
1453 'with match parameter' ,
1554 buildTestsRunner (
0 commit comments