@@ -79,7 +79,7 @@ describe.skip('Bookshop - Search', () => {
79
79
// ad-hoc search expression
80
80
Books [ '@cds.search.authorsAddress' ] = true
81
81
82
- let res = await SELECT . from ( Books ) . columns ( 'author.name as author' , 'title' ) . search ( '1 Main Street, Bradford' )
82
+ let res = await SELECT . from ( Books ) . columns ( 'author.name as author' , 'title' ) . search ( '" 1 Main Street, Bradford" ' )
83
83
// author name in res[0] must match "Emily Brontë"
84
84
expect ( res . length ) . to . be . eq ( 1 )
85
85
expect ( res [ 0 ] . author ) . to . be . eq ( 'Emily Brontë' )
@@ -91,12 +91,34 @@ describe.skip('Bookshop - Search', () => {
91
91
Books [ '@cds.search.author' ] = true
92
92
Authors [ '@cds.search.address' ] = true // address is a calculated element
93
93
94
- let res = await SELECT . from ( Books ) . columns ( 'author.name as author' , 'title' ) . search ( '1 Main Street, Bradford' )
94
+ let res = await SELECT . from ( Books ) . columns ( 'author.name as author' , 'title' ) . search ( '" 1 Main Street, Bradford" ' )
95
95
// author name in res[0] must match "Emily Brontë"
96
96
expect ( res . length ) . to . be . eq ( 1 )
97
97
expect ( res [ 0 ] . author ) . to . be . eq ( 'Emily Brontë' )
98
98
} )
99
99
100
+ test ( 'Search escaped character in search literal' , async ( ) => {
101
+ const { Books } = cds . entities
102
+ const { Authors } = cds . entities
103
+ // ad-hoc search expression
104
+ Books [ '@cds.search.author' ] = true
105
+ Authors [ '@cds.search.address' ] = true // address is a calculated element
106
+
107
+ let res = await SELECT . from ( Books ) . columns ( 'author.name as author' , 'title' ) . search ( '"\\"\\\\"' )
108
+ expect ( res . length ) . to . be . eq ( 0 )
109
+ } )
110
+
111
+ test ( 'Search improperly escaped character in search literal' , async ( ) => {
112
+ const { Books } = cds . entities
113
+ const { Authors } = cds . entities
114
+ // ad-hoc search expression
115
+ Books [ '@cds.search.author' ] = true
116
+ Authors [ '@cds.search.address' ] = true // address is a calculated element
117
+
118
+ let res = await SELECT . from ( Books ) . columns ( 'author.name as author' , 'title' ) . search ( '"\\q"' )
119
+ expect ( res . length ) . to . be . eq ( 0 )
120
+ } )
121
+
100
122
test ( 'search on result of subselect' , async ( ) => {
101
123
const res = await cds . run (
102
124
SELECT . from ( SELECT . from ( { ref : [ 'sap.capire.bookshop.Books' ] } ) . columns ( 'title' ) )
0 commit comments