Show table constraints
This commit is contained in:
@@ -136,6 +136,16 @@ func (client *Client) TableIndexes(table string) (*Result, error) {
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (client *Client) TableConstraints(table string) (*Result, error) {
|
||||
res, err := client.query(statements.PG_TABLE_CONSTRAINTS, table)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (client *Client) Sequences() ([]string, error) {
|
||||
return client.fetchRows(statements.PG_SEQUENCES)
|
||||
}
|
||||
|
||||
@@ -188,6 +188,14 @@ func test_TableIndexes(t *testing.T) {
|
||||
assert.Equal(t, 2, len(res.Rows))
|
||||
}
|
||||
|
||||
func test_TableConstraints(t *testing.T) {
|
||||
res, err := testClient.TableConstraints("editions")
|
||||
|
||||
assert.Equal(t, nil, err)
|
||||
assert.Equal(t, 1, len(res.Columns))
|
||||
assert.Equal(t, 2, len(res.Rows))
|
||||
}
|
||||
|
||||
func test_Sequences(t *testing.T) {
|
||||
res, err := testClient.Sequences()
|
||||
|
||||
@@ -271,6 +279,7 @@ func TestAll(t *testing.T) {
|
||||
test_TableRows(t)
|
||||
test_TableInfo(t)
|
||||
test_TableIndexes(t)
|
||||
test_TableConstraints(t)
|
||||
test_Sequences(t)
|
||||
test_Query(t)
|
||||
test_QueryError(t)
|
||||
|
||||
Reference in New Issue
Block a user