Support concatenation filter #62

Open
opened 2019-10-30 18:21:41 +00:00 by SijmenSchoon · 2 comments
Contributor

There currently is no way to concatenate two strings in all supported engines:

RDBMS Operator Function
MySQL a ∣∣ b CONCAT(a, b)
PostgreSQL a ∣∣ b CONCAT(a, b)
Oracle a ∣∣ b CONCAT(a, b)
MS SQL a + b CONCAT(a, b)
SQLite a ∣∣ b -

Thanks to MS SQL and SQLite, there is no common solution. Adding a filter to replace e.g. || with + for MS SQL will fix this problem.

There currently is no way to concatenate two strings in all supported engines: RDBMS | Operator | Function -----------|----------|---------- MySQL | `a ∣∣ b` | `CONCAT(a, b)` PostgreSQL | `a ∣∣ b` | `CONCAT(a, b)` Oracle | `a ∣∣ b` | `CONCAT(a, b)` MS SQL | `a + b` | `CONCAT(a, b)` SQLite | `a ∣∣ b` | - Thanks to MS SQL and SQLite, there is no common solution. Adding a filter to replace e.g. `||` with `+` for MS SQL will fix this problem.
Owner

@SijmenSchoon what do you want to use them? Could you give some example?

@SijmenSchoon what do you want to use them? Could you give some example?
Author
Contributor

I want to use it for a gitea migration:

_, err := x.Exec("UPDATE `issue` SET `ref` = 'refs/heads/' || `ref`")

This query does not work on MS SQL, because it expects a + for concatenation, and

_, err := x.Exec("UPDATE `issue` SET `ref` = CONCAT('refs/heads/', `ref`)")

does not work for SQLite, since it does not support CONCAT.

I want to use it for a [gitea migration](https://github.com/go-gitea/gitea/pull/8742): ```go _, err := x.Exec("UPDATE `issue` SET `ref` = 'refs/heads/' || `ref`") ``` This query does not work on MS SQL, because it expects a `+` for concatenation, and ```go _, err := x.Exec("UPDATE `issue` SET `ref` = CONCAT('refs/heads/', `ref`)") ``` does not work for SQLite, since it does not support `CONCAT`.
This repo is archived. You cannot comment on issues.
No Milestone
No Assignees
2 Participants
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: xorm/core#62
No description provided.