Skip to content

Commit

Permalink
Fix LENGTH function name across databases
Browse files Browse the repository at this point in the history
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
  • Loading branch information
come-nc committed Dec 19, 2022
1 parent 6e3cd43 commit 6185e32
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function octetLength($field, $alias = ''): IQueryFunction {
public function charLength($field, $alias = ''): IQueryFunction {
$alias = $alias ? (' AS ' . $this->helper->quoteColumnName($alias)) : '';
$quotedName = $this->helper->quoteColumnName($field);
return new QueryFunction('LENGTH(' . $quotedName . ')' . $alias);
return new QueryFunction('CHAR_LENGTH(' . $quotedName . ')' . $alias);
}

public function max($field): IQueryFunction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,10 @@ public function octetLength($field, $alias = ''): IQueryFunction {
$quotedName = $this->helper->quoteColumnName($field);
return new QueryFunction('LENGTHB(' . $quotedName . ')' . $alias);
}

public function charLength($field, $alias = ''): IQueryFunction {
$alias = $alias ? (' AS ' . $this->helper->quoteColumnName($alias)) : '';
$quotedName = $this->helper->quoteColumnName($field);
return new QueryFunction('LENGTH(' . $quotedName . ')' . $alias);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,10 @@ public function octetLength($field, $alias = ''): IQueryFunction {
$quotedName = $this->helper->quoteColumnName($field);
return new QueryFunction('LENGTH(CAST(' . $quotedName . ' as BLOB))' . $alias);
}

public function charLength($field, $alias = ''): IQueryFunction {
$alias = $alias ? (' AS ' . $this->helper->quoteColumnName($alias)) : '';
$quotedName = $this->helper->quoteColumnName($field);
return new QueryFunction('LENGTH(' . $quotedName . ')' . $alias);
}
}

0 comments on commit 6185e32

Please sign in to comment.