mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 09:05:55 +00:00
update like to wrap between % if no wildcard is given
This commit is contained in:
parent
af83e61101
commit
732040dc80
2 changed files with 17 additions and 2 deletions
|
|
@ -103,7 +103,18 @@ describe('set types', () => {
|
|||
}])).toEqual({ error: false, query: 'Not(Union(Row(fieldName="one"), Row(fieldName="two")))' })
|
||||
});
|
||||
|
||||
it('stringifies like operator', () => {
|
||||
it('stringifies like operator with a wildcard', () => {
|
||||
expect(stringifyRowData([{
|
||||
row: [{
|
||||
"field": "fieldName",
|
||||
"rowOperator": "like",
|
||||
"value": "value%",
|
||||
"type": "set"
|
||||
}]
|
||||
}])).toEqual({ error: false, query: 'UnionRows(Rows(field=fieldName, like="value%"))' })
|
||||
});
|
||||
|
||||
it('stringifies like operator without a wildcard', () => {
|
||||
expect(stringifyRowData([{
|
||||
row: [{
|
||||
"field": "fieldName",
|
||||
|
|
|
|||
|
|
@ -30,7 +30,11 @@ export const stringifyRowData = (rowData: RowGrouping[], operator?: Operator) =>
|
|||
return { error: true, query: error.message };
|
||||
}
|
||||
} else if (rowOperator === 'like') {
|
||||
rowString = `UnionRows(Rows(field=${field}, like="%${value}%"))`;
|
||||
if (value.includes('%')) {
|
||||
rowString = `UnionRows(Rows(field=${field}, like="${value}"))`;
|
||||
} else {
|
||||
rowString = `UnionRows(Rows(field=${field}, like="%${value}%"))`;
|
||||
}
|
||||
} else {
|
||||
rowString = ['set', 'timestamp'].includes(type)
|
||||
? `Row(${field}${operator}"${value}")`
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue