forcedotcom / forcedotcom/Salesforce-CDP-jdbc

Support Primary Key Metadata

Open
#181 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
41
Forks
29
PR merge metrics
No merged PRs in 30d

Description

We are trying to get metadata on the Primary Keys using the `QueryServiceMetadata` class `getPrimaryKeys()` method which looks to currently always return an empty list.

```
public ResultSet getPrimaryKeys(String catalog, String schema, String table) throws SQLException {
return new QueryServiceResultSet(Collections.EMPTY_LIST, new QueryServiceResultSetMetaData(QueryServiceDbMetadata.GET_PRIMARY_KEYS));
}
```

From a quick query, we can see that Salesforce does indeed return information about the Primary Keys for each table and looks to be possible to implement.

Example Salesforce Metadata:
```
{
"metadata": [
{
"fields": [
{
"name": "AccountNumber__c",
"displayName": "Account Number",
"type": "STRING",
"businessType": "TEXT"
},
{
"name": "AccountSource__c",
"displayName": "Account Source",
"type": "STRING",
"businessType": "TEXT"
},
{
"name": "AnnualRevenue__c",
"displayName": "Annual Revenue",
"type": "NUMBER",
"businessType": "NUMBER"
},
{
"name": "BillingCity__c",
"displayName": "Billing City",
"type": "STRING",
"businessType": "TEXT"
},
{
"name": "BillingCountry__c",
"displayName": "Billing Country",
"type": "STRING",
"businessType": "TEXT"
},
{
"name": "BillingGeocodeAccuracy__c",
"displayName": "Billing Geocode Accuracy",
"type": "STRING",
"businessType": "TEXT"
},
{
"name": "BillingLatitude__c",
"displayName": "Billing Latitude",
"type": "NUMBER",
"businessType": "NUMBER"
},
{
"name": "BillingLongitude__c",
"displayName": "Billing Longitude",
"type": "NUMBER",
"businessType": "NUMBER"
},
{
"name": "BillingPostalCode__c",
"displayName": "Billing Zip/Postal Code",
"type": "STRING",
"businessType": "TEXT"
},
{
"name": "BillingState__c",
"displayName": "Billing State/Province",
"type": "STRING",
"businessType": "TEXT"
},
{
"name": "BillingStreet__c",
"displayName": "Billing Street",
"type": "STRING",
"businessType": "TEXT"
},
{
"name": "cdp_sys_SourceVersion__c",
"displayName": "cdp_sys_SourceVersion",
"type": "STRING",
"businessType": "TEXT"
},
{
"name": "CreatedById__c",
"displayName": "Created By ID",
"type": "STRING",
"businessType": "TEXT"
},
{
"name": "CreatedDate__c",
"displayName": "Created Date",
"type": "DATE_TIME",
"businessType": "DATE_TIME"
},
{
"name": "DataSource__c",
"displayName": "Data Source",
"type": "STRING",
"businessType": "TEXT"
},
{
"name": "DataSourceObject__c",
"displayName": "Data Source Object",
"type": "STRING",
"businessType": "TEXT"
},
{
"name": "Description__c",
"displayName": "Account Description",
"type": "STRING",
"businessType": "TEXT"
},
{
"name": "Fax__c",
"displayName": "Account Fax",
"type": "STRING",
"businessType": "TEXT"
},
{
"name": "Id__c",
"displayName": "Account ID",
"type": "STRING",
"keyQualifier": "KQ_Id__c",
"businessType": "TEXT"
},
{
"name": "Industry__c",
"displayName": "Industry",
"type": "STRING",
"businessType": "TEXT"
},
{
"name": "IsDeleted__c",
"displayName": "Deleted",
"type": "STRING",
"businessType": "TEXT"
},
{
"name": "Jigsaw__c",
"displayName": "Data.com Key",
"type": "STRING",
"businessType": "TEXT"
},
{
"name": "JigsawCompanyId__c",
"displayName": "Jigsaw Company ID",
"type": "STRING",
"businessType": "TEXT"
},
{
"name": "KQ_Id__c",
"displayName": "KQ_Id",
"type": "STRING",
"businessType": "TEXT"
},
{
"name": "LastActivityDate__c",
"displayName": "Last Activity",
"type": "DATE_TIME",
"businessType": "DATE_TIME"
},
{
"name": "LastModifiedById__c",
"displayName": "Last Modified By ID",
"type": "STRING",
"businessType": "TEXT"
},
{
"name": "LastModifiedDate__c",
"displayName": "Last Modified Date",
"type": "DATE_TIME",
"businessType": "DATE_TIME"
},
{
"name": "LastReferencedDate__c",
"displayName": "Last Referenced Date",
"type": "DATE_TIME",
"businessType": "DATE_TIME"
},
{
"name": "LastViewedDate__c",
"displayName": "Last Viewed Date",
"type": "DATE_TIME",
"businessType": "DATE_TIME"
},
{
"name": "MasterRecordId__c",
"displayName": "Master Record ID",
"type": "STRING",
"businessType": "TEXT"
},
{
"name": "Name__c",
"displayName": "Account Name",
"type": "STRING",
"businessType": "TEXT"
},
{
"name": "NumberOfEmployees__c",
"displayName": "Employees",
"type": "NUMBER",
"businessType": "NUMBER"
},
{
"name": "OwnerId__c",
"displayName": "Owner ID",
"type": "STRING",
"businessType": "TEXT"
},
{
"name": "ParentId__c",
"displayName": "Parent Account ID",
"type": "STRING",
"businessType": "TEXT"
},
{
"name": "Phone__c",
"displayName": "Account Phone",
"type": "STRING",
"businessType": "TEXT"
},
{
"name": "PhotoUrl__c",
"displayName": "Photo URL",
"type": "STRING",
"businessType": "TEXT"
},
{
"name": "SfdcOrganizationId__c",
"displayName": "SfdcOrganizationId",
"type": "STRING",
"businessType": "TEXT"
},
{
"name": "ShippingCity__c",
"displayName": "Shipping City",
"type": "STRING",
"businessType": "TEXT"
},
{
"name": "ShippingCountry__c",
"displayName": "Shipping Country",
"type": "STRING",
"businessType": "TEXT"
},
{
"name": "ShippingGeocodeAccuracy__c",
"displayName": "Shipping Geocode Accuracy",
"type": "STRING",
"businessType": "TEXT"
},
{
"name": "ShippingLatitude__c",
"displayName": "Shipping Latitude",
"type": "NUMBER",
"businessType": "NUMBER"
},
{
"name": "ShippingLongitude__c",
"displayName": "Shipping Longitude",
"type": "NUMBER",
"businessType": "NUMBER"
},
{
"name": "ShippingPostalCode__c",
"displayName": "Shipping Zip/Postal Code",
"type": "STRING",
"businessType": "TEXT"
},
{
"name": "ShippingState__c",
"displayName": "Shipping State/Province",
"type": "STRING",
"businessType": "TEXT"
},
{
"name": "ShippingStreet__c",
"displayName": "Shipping Street",
"type": "STRING",
"businessType": "TEXT"
},
{
"name": "SicDesc__c",
"displayName": "SIC Description",
"type": "STRING",
"businessType": "TEXT"
},
{
"name": "SystemModstamp__c",
"displayName": "System Modstamp",
"type": "DATE_TIME",
"businessType": "DATE_TIME"
},
{
"name": "Type__c",
"displayName": "Account Type",
"type": "STRING",
"businessType": "TEXT"
},
{
"name": "Website__c",
"displayName": "Website",
"type": "STRING",
"businessType": "TEXT"
}
],
"category": "Profile",
"name": "Account_Home__dll",
"displayName": "Account_Home",
"primaryKeys": [
{
"name": "Id__c",
"displayName": "Account ID",
"indexOrder": "1"
}
]
}
]
}

```

Is there any plans for the implementation?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with QueryServiceMetadata.getPrimaryKeys() and the QueryServiceResultSet and QueryServiceResultSetMetaData classes shown in the issue. Compare the Salesforce metadata response with the JDBC primary-key metadata contract, then add coverage for a table that reports primary-key information. Done means getPrimaryKeys() returns the available primary-key metadata instead of an empty result.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
databases
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.