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

Need multiple primary key results #116

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
11 changes: 11 additions & 0 deletions lib/dialects/mssql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,17 @@ export default class MSSQL implements SchemaInspector {
return columnName as string;
}

/**
* Get the primarys key column for the given table
*/
async primarys(table: string) {

const results = await this.knex.raw("EXEC sp_pkeys ?",[table])

const columnName = results.length > 0 ? results : null;
return columnName as object;
}

// Foreign Keys
// ===============================================================================================

Expand Down
1 change: 1 addition & 0 deletions lib/types/schema-inspector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface SchemaInspector {

hasColumn(table: string, column: string): Promise<boolean>;
primary(table: string): Promise<string | null>;
primarys(table: string): Promise<object | null>;

foreignKeys(table?: string): Promise<ForeignKey[]>;

Expand Down