Skip to content

Commit

Permalink
feat: access public synonyms
Browse files Browse the repository at this point in the history
  • Loading branch information
gregorwolf committed Nov 6, 2022
1 parent 40facec commit 9ffc055
Show file tree
Hide file tree
Showing 8 changed files with 277 additions and 2 deletions.
83 changes: 83 additions & 0 deletions db-hana/externalTypes.cds
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
namespace PUBLIC;

@cds.persistence.exists
entity DUMMY {
DUMMY : String(1)
@title : 'Dummy';
}

// needed for sap_cpe_BASICS.hdblibrary
@cds.persistence.exists
entity TABLE_COLUMNS {
SCHEMA_NAME : String(256)
@title : 'Schema name';
TABLE_NAME : String(256)
@title : 'Table name';
TABLE_OID : Integer64
@title : 'Object ID of the table';
COLUMN_NAME : String(256)
@title : 'Name of the column';
POSITION : Integer
@title : 'Ordinal position of the column in the record';
DATA_TYPE_ID : hana.SMALLINT
@title : 'SQL Data type ID of the column';
DATA_TYPE_NAME : String(16)
@title : 'SQL data type name of the column';
OFFSET : hana.SMALLINT
@title : 'Offset of the column in the record';
LENGTH : Integer
@title : 'Length';
SCALE : Integer
@title : 'Scale';
IS_NULLABLE : String(5)
@title : 'Is Nullable (TRUE/FALSE)';
DEFAULT_VALUE : String(5000)
@title : 'Default value';
COMMENTS : String(5000)
@title : 'Comments';
}

// needed for sap_cpe_BASICS.hdblibrary
@cds.persistence.exists
entity VIEW_COLUMNS {
SCHEMA_NAME : String(256)
@title : 'Schema name';
VIEW_NAME : String(256)
@title : 'View name';
VIEW_OID : Integer64
@title : 'Object ID of the view';
COLUMN_NAME : String(256)
@title : 'Name of the column';
POSITION : Integer
@title : 'Ordinal position of the column in the record';
DATA_TYPE_ID : hana.SMALLINT
@title : 'SQL Data type ID of the column';
DATA_TYPE_NAME : String(16)
@title : 'SQL data type name of the column';
OFFSET : hana.SMALLINT
@title : 'Offset of the column in the record';
LENGTH : Integer
@title : 'Length';
SCALE : Integer
@title : 'Scale';
IS_NULLABLE : String(5)
@title : 'Is Nullable (TRUE/FALSE)';
DEFAULT_VALUE : String(5000)
@title : 'Default value';
COMMENTS : String(5000)
@title : 'Comments';
}

@cds.persistence.exists
entity SYNONYMS {
SCHEMA_NAME : String(256) @title : 'Synonym schema name';
SYNONYM_NAME : String(256) @title : 'Synonym name';
key SYNONYM_OID : Integer64 @title : 'Object ID of the Synonym';
OBJECT_DATABASE_SCHEMA : String(256) @title : 'Object Database Schema';
OBJECT_DATABASE : String(256) @title : 'Object Database';
OBJECT_SCHEMA : String(256) @title : 'Object schema';
OBJECT_NAME : String(256) @title : 'Object name';
OBJECT_TYPE : String(256) @title : 'Object type';
IS_COLUMN_OBJECT : Boolean @title : 'Is column object';
IS_VALID : Boolean @title : 'Is valid';
}
136 changes: 136 additions & 0 deletions db/src/.hdiconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
{
"file_suffixes": {
"csv": {
"plugin_name": "com.sap.hana.di.tabledata.source"
},
"hdbafllangprocedure": {
"plugin_name": "com.sap.hana.di.afllangprocedure"
},
"hdbanalyticprivilege": {
"plugin_name": "com.sap.hana.di.analyticprivilege"
},
"hdbcalculationview": {
"plugin_name": "com.sap.hana.di.calculationview"
},
"hdbcollection": {
"plugin_name": "com.sap.hana.di.collection"
},
"hdbconstraint": {
"plugin_name": "com.sap.hana.di.constraint"
},
"hdbdropcreatetable": {
"plugin_name": "com.sap.hana.di.dropcreatetable"
},
"hdbflowgraph": {
"plugin_name": "com.sap.hana.di.flowgraph"
},
"hdbfunction": {
"plugin_name": "com.sap.hana.di.function"
},
"hdbgraphworkspace": {
"plugin_name": "com.sap.hana.di.graphworkspace"
},
"hdbhadoopmrjob": {
"plugin_name": "com.sap.hana.di.virtualfunctionpackage.hadoop"
},
"hdbindex": {
"plugin_name": "com.sap.hana.di.index"
},
"hdblibrary": {
"plugin_name": "com.sap.hana.di.library"
},
"hdbmigrationtable": {
"plugin_name": "com.sap.hana.di.table.migration"
},
"hdbprocedure": {
"plugin_name": "com.sap.hana.di.procedure"
},
"hdbprojectionview": {
"plugin_name": "com.sap.hana.di.projectionview"
},
"hdbprojectionviewconfig": {
"plugin_name": "com.sap.hana.di.projectionview.config"
},
"hdbreptask": {
"plugin_name": "com.sap.hana.di.reptask"
},
"hdbresultcache": {
"plugin_name": "com.sap.hana.di.resultcache"
},
"hdbrole": {
"plugin_name": "com.sap.hana.di.role"
},
"hdbroleconfig": {
"plugin_name": "com.sap.hana.di.role.config"
},
"hdbsearchruleset": {
"plugin_name": "com.sap.hana.di.searchruleset"
},
"hdbsequence": {
"plugin_name": "com.sap.hana.di.sequence"
},
"hdbstatistics": {
"plugin_name": "com.sap.hana.di.statistics"
},
"hdbstructuredprivilege": {
"plugin_name": "com.sap.hana.di.structuredprivilege"
},
"hdbsynonym": {
"plugin_name": "com.sap.hana.di.synonym"
},
"hdbsynonymconfig": {
"plugin_name": "com.sap.hana.di.synonym.config"
},
"hdbsystemversioning": {
"plugin_name": "com.sap.hana.di.systemversioning"
},
"hdbtable": {
"plugin_name": "com.sap.hana.di.table"
},
"hdbtabledata": {
"plugin_name": "com.sap.hana.di.tabledata"
},
"hdbtabletype": {
"plugin_name": "com.sap.hana.di.tabletype"
},
"hdbtrigger": {
"plugin_name": "com.sap.hana.di.trigger"
},
"hdbview": {
"plugin_name": "com.sap.hana.di.view"
},
"hdbvirtualfunction": {
"plugin_name": "com.sap.hana.di.virtualfunction"
},
"hdbvirtualfunctionconfig": {
"plugin_name": "com.sap.hana.di.virtualfunction.config"
},
"hdbvirtualpackagehadoop": {
"plugin_name": "com.sap.hana.di.virtualpackage.hadoop"
},
"hdbvirtualpackagesparksql": {
"plugin_name": "com.sap.hana.di.virtualpackage.sparksql"
},
"hdbvirtualprocedure": {
"plugin_name": "com.sap.hana.di.virtualprocedure"
},
"hdbvirtualprocedureconfig": {
"plugin_name": "com.sap.hana.di.virtualprocedure.config"
},
"hdbvirtualtable": {
"plugin_name": "com.sap.hana.di.virtualtable"
},
"hdbvirtualtableconfig": {
"plugin_name": "com.sap.hana.di.virtualtable.config"
},
"properties": {
"plugin_name": "com.sap.hana.di.tabledata.properties"
},
"tags": {
"plugin_name": "com.sap.hana.di.tabledata.properties"
},
"txt": {
"plugin_name": "com.sap.hana.di.copyonly"
}
}
}
8 changes: 8 additions & 0 deletions db/src/synonyms.hdbsynonym
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"PUBLIC_SYNONYMS" : {
"target": {
"object" : "SYNONYMS",
"schema" : "SYS"
}
}
}
8 changes: 8 additions & 0 deletions db/src/tableColumns.hdbsynonym
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"PUBLIC_TABLE_COLUMNS" : {
"target": {
"object" : "TABLE_COLUMNS",
"schema": "SYS"
}
}
}
8 changes: 8 additions & 0 deletions db/src/viewColumns.hdbsynonym
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"PUBLIC_VIEW_COLUMNS" : {
"target": {
"object" : "VIEW_COLUMNS",
"schema" : "SYS"
}
}
}
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,16 @@
},
"db-ext": {
"[hybrid]": {
"model": "db-hana"
"model": [
"db-hana",
"srv-hana"
]
},
"[production]": {
"model": "db-hana"
"model": [
"db-hana",
"srv-hana"
]
}
}
},
Expand Down
12 changes: 12 additions & 0 deletions srv-hana/PublicSynonymsService.cds
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace external;

using {PUBLIC} from '../db-hana/externalTypes';

@(requires : ['admin', ])
service PublicSynonymsService {

entity Synonyms as projection on PUBLIC.SYNONYMS;
entity TableColumns as projection on PUBLIC.TABLE_COLUMNS;
entity ViewColumns as projection on PUBLIC.VIEW_COLUMNS;

}
14 changes: 14 additions & 0 deletions tests/public-synonyms.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
###
GET http://localhost:4004/public-synonyms/
Authorization: Basic admin:
###
GET http://localhost:4004/public-synonyms/Synonyms
Authorization: Basic admin:
###
GET http://localhost:4004/public-synonyms/TableColumns
?$top=10
Authorization: Basic admin:
###
GET http://localhost:4004/public-synonyms/ViewColumns
?$top=10
Authorization: Basic admin:

0 comments on commit 9ffc055

Please sign in to comment.