Add AS helper function #91

Closed
imle wants to merge 1 commits from add-as-function into master
Contributor

This is just a quality of life function to turn this:

stmt.LeftJoin(TableNameUsers + " u")
stmt.LeftJoin(TableNameUsers + " " + TableNameUsersAlias)

Into the slightly more readable:

stmt.LeftJoin(builder.As(TableNameUsers, "u"))
stmt.LeftJoin(builder.As(TableNameUsers, TableNameUsersAlias))

Open to other options for how to solve this, but the As approach seemed the least intrusive and most backwards compatible.

This is just a quality of life function to turn this: ``` stmt.LeftJoin(TableNameUsers + " u") stmt.LeftJoin(TableNameUsers + " " + TableNameUsersAlias) ``` Into the slightly more readable: ``` stmt.LeftJoin(builder.As(TableNameUsers, "u")) stmt.LeftJoin(builder.As(TableNameUsers, TableNameUsersAlias)) ``` Open to other options for how to solve this, but the `As` approach seemed the least intrusive and most backwards compatible.
Owner

This is just a quality of life function to turn this:

stmt.LeftJoin(TableNameUsers + " u")
stmt.LeftJoin(TableNameUsers + " " + TableNameUsersAlias)

Into the slightly more readable:

stmt.LeftJoin(builder.As(TableNameUsers, "u"))
stmt.LeftJoin(builder.As(TableNameUsers, TableNameUsersAlias))

Open to other options for how to solve this, but the As approach seemed the least intrusive and most backwards compatible.

Different database use different syntax, some needs a AS keyword, another needs a space.

> This is just a quality of life function to turn this: > ``` > stmt.LeftJoin(TableNameUsers + " u") > stmt.LeftJoin(TableNameUsers + " " + TableNameUsersAlias) > ``` > > Into the slightly more readable: > ``` > stmt.LeftJoin(builder.As(TableNameUsers, "u")) > stmt.LeftJoin(builder.As(TableNameUsers, TableNameUsersAlias)) > ``` > > Open to other options for how to solve this, but the `As` approach seemed the least intrusive and most backwards compatible. Different database use different syntax, some needs a `AS` keyword, another needs a space.
imle force-pushed add-as-function from 23218801ec to 2394514719 2022-08-10 06:50:54 +00:00 Compare
Author
Contributor

I took a look at this site: https://www.techonthenet.com/

The info I saw there was as follows:

sqlite:   table_name [ AS ] alias_name
mssql:    table_name [ AS ] alias_name
postgres: table_name [ AS ] alias_name
mysql:    table_name [ AS ] alias_name
oracle:   table_name alias_name

https://www.techonthenet.com/sqlite/alias.php
https://www.techonthenet.com/sql_server/alias.php
https://www.techonthenet.com/postgresql/alias.php
https://www.techonthenet.com/mysql/alias.php
https://www.techonthenet.com/oracle/alias.php

I can alter the PR to be more like the following if that would be preferred:
https://gitea.com/xorm/builder/compare/master...imle:add-as-function-v2

I took a look at this site: https://www.techonthenet.com/ The info I saw there was as follows: ``` sqlite: table_name [ AS ] alias_name mssql: table_name [ AS ] alias_name postgres: table_name [ AS ] alias_name mysql: table_name [ AS ] alias_name oracle: table_name alias_name ``` https://www.techonthenet.com/sqlite/alias.php https://www.techonthenet.com/sql_server/alias.php https://www.techonthenet.com/postgresql/alias.php https://www.techonthenet.com/mysql/alias.php https://www.techonthenet.com/oracle/alias.php I can alter the PR to be more like the following if that would be preferred: https://gitea.com/xorm/builder/compare/master...imle:add-as-function-v2
imle closed this pull request 2022-09-27 18:32:57 +00:00
All checks were successful
continuous-integration/drone/pr Build is passing

Pull request closed

Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
2 Participants
Notifications
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/builder#91
No description provided.