Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to add table title to dbconfig.js #161

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions conf/dbconfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ module.exports = {
searchField: 'fastighetsbeteckning',
schema: 'public',
geometryName: 'geom',
title: 'Fastigheter',
useCentroid: true
},
{
Expand Down
7 changes: 6 additions & 1 deletion models/mssqldefault.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,19 @@ var mssqlDefault = function mssqlDefault(queryString, queryOptions, defaultLimit
geometryField + ".ToString() AS GEOM " + " ";
var sqlFields = fields ? fields.join(',') + "," : "";
var type = " '" + table + "'" + " AS TYPE, ";
var title = queryOptions.title ? " '" + queryOptions.title + "'" + ' AS "TITLE", ' : '';
var condition = queryString;
var searchString;
var limitNumber = queryOptions.limit || defaultLimit || 1000;
var limit = "TOP " + limitNumber.toString() + " ";

searchString =
"SELECT " + limit +
sqlSearchField + sqlFields + type + wkt +
sqlSearchField +
sqlFields +
type +
title +
wkt +
" FROM " + database + "." + schema + "." + table +
" WHERE LOWER(" + searchField + ") LIKE LOWER('" + condition + "%')" + " " +
" ORDER BY " + searchField + "";
Expand Down
7 changes: 6 additions & 1 deletion models/oracledefault.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var oracleDefault = function oracleDefault(queryString, queryOptions) {
var wkt = useCentroid ? "TO_CHAR(SDO_UTIL.TO_WKTGEOMETRY(SDO_GEOM.SDO_CENTROID(" + geometryField + ", m.diminfo))) AS GEOM" :
"TO_CHAR(SDO_UTIL.TO_WKTGEOMETRY(" + geometryField + ")) AS GEOM";
var sqlFields = fields ? fields.join(',') + "," : "";
var title = queryOptions.title ? " '" + queryOptions.title + "'" + ' AS TITLE, ' : '';
var condition = queryString;
var searchString;
var sdo_geom_metadata;
Expand All @@ -20,7 +21,11 @@ var oracleDefault = function oracleDefault(queryString, queryOptions) {
}

searchString =
"SELECT " + sqlSearchField + sqlFields + "'" + table + "'" + " AS type," +
"SELECT " +
sqlSearchField +
sqlFields +
"'" + table + "'" + " AS type," +
title +
wkt + " " +
"FROM " + schema + "." + table + ", user_sdo_geom_metadata m " +
"WHERE " + sdo_geom_metadata + "' AND lower(" + searchField + ") LIKE lower('" + condition + "%')" + " " +
Expand Down
2 changes: 2 additions & 0 deletions models/pgdefault.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var pgDefault = function pgDefault(queryString, queryOptions, defaultLimit) {
'ST_AsText("' + table + '"."' + geometryField + '") AS "GEOM" ';
var sqlFields = fields ? fields.join(',') + "," : "";
var type = " '" + table + "'" + ' AS "TYPE", ';
var title = queryOptions.title ? " '" + queryOptions.title + "'" + ' AS "TITLE", ' : '';
var condition = queryString;
var searchString;
var limitNumber = queryOptions.limit || defaultLimit || 1000;
Expand All @@ -22,6 +23,7 @@ var pgDefault = function pgDefault(queryString, queryOptions, defaultLimit) {
' "' + table + '"."' + gid + '" AS "GID", ' +
sqlFields +
type +
title +
wkt +
' FROM ' + schema + '."' + table + '"' +
' WHERE LOWER(CAST("' + table + '"."' + searchField + '"' + " AS TEXT)) ILIKE LOWER('" + condition + "%')" +
Expand Down