Skip to content

Commit c9e1c44

Browse files
committed
feat: query to fetch unique columns
Signed-off-by: Muhammad Aaqil <[email protected]>
1 parent 7942e74 commit c9e1c44

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

test/postgresql.discover.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,17 @@ describe('Discover LDL schema from a table', function() {
394394
});
395395
});
396396

397+
describe('Discover unique properties', function() {
398+
it('should validate unique key for user', function() {
399+
db.discoverSchema('user', {owner: 'strongloop'}, function(err, schema) {
400+
console.log('This is our err: ', err);
401+
console.log('This is our schema: ', schema);
402+
assert(schema.properties.email.index.unique, true);
403+
done(null, schema);
404+
});
405+
});
406+
});
407+
397408
describe('Discover and map correctly database types', function() {
398409
it('should handle character varying, date, timestamp with time zone, timestamp without time zone', function(done) {
399410
db.discoverSchema('customer', {owner: 'strongloop'}, function(err, schema) {

test/schema.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ CREATE TABLE "user" (
276276
email character varying(100)
277277
);
278278

279+
ALTER TABLE "user" ADD CONSTRAINT user_email_unique UNIQUE (email);
279280
--
280281
-- Name: GeoPoint_id_seq; Type: SEQUENCE; Schema: strongloop; Owner: strongloop
281282
--

0 commit comments

Comments
 (0)