@@ -6,10 +6,55 @@ 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 IP addresses' , ( ) => {
29+ const builder = new PsqlQueryBuilder ( { match : 'test' } ) ;
30+ const result = ( builder as AnyObject ) . _formatAndSanitize ( '192.168.1.1' ) ;
31+ expect ( result ) . to . equal ( '192.168.1.1:*' ) ;
32+ } ) ;
33+
34+ it ( 'should handle multiple dots in different positions' , ( ) => {
35+ const builder = new PsqlQueryBuilder ( { match : 'test' } ) ;
36+ const result = ( builder as AnyObject ) . _formatAndSanitize (
37+ 'Project.Alpha.Beta' ,
38+ ) ;
39+ expect ( result ) . to . equal ( 'Project.Alpha.Beta:*' ) ;
40+ } ) ;
41+
42+ it ( 'should handle mix of dots and special characters' , ( ) => {
43+ const builder = new PsqlQueryBuilder ( { match : 'test' } ) ;
44+ const result = ( builder as AnyObject ) . _formatAndSanitize (
45+ 'Deal.10 & Test.1.5' ,
46+ ) ;
47+ expect ( result ) . to . equal ( 'Deal.10:*<->Test.1.5:*' ) ;
48+ } ) ;
49+
50+ it ( 'should handle complex search with dots and spaces' , ( ) => {
51+ const builder = new PsqlQueryBuilder ( { match : 'test' } ) ;
52+ const result = ( builder as AnyObject ) . _formatAndSanitize (
53+ 'Version 2.5 (Release)' ,
54+ ) ;
55+ expect ( result ) . to . equal ( 'Version:*<->2.5:*<->Release:*' ) ;
56+ } ) ;
57+ } ) ;
1358 describe (
1459 'with match parameter' ,
1560 buildTestsRunner (
0 commit comments