From 379b9524a36d1c7a0f31a7411c7abc8754eb3a7f Mon Sep 17 00:00:00 2001 From: Tim <0xtimc@gmail.com> Date: Tue, 21 Feb 2017 12:34:48 +0000 Subject: [PATCH] Changes as per code review --- Sources/Fluent/Relations/Children.swift | 2 +- Tests/FluentTests/ChildTests.swift | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Sources/Fluent/Relations/Children.swift b/Sources/Fluent/Relations/Children.swift index bb108dad..309f9ef8 100644 --- a/Sources/Fluent/Relations/Children.swift +++ b/Sources/Fluent/Relations/Children.swift @@ -14,7 +14,7 @@ extension Children: QueryRepresentable { throw RelationError.noIdentifier } - let foreignId = foreignKey ?? "\(type(of: parent))_\(T.idKey)".lowercased() + let foreignId = foreignKey ?? "\(type(of: parent).name)_\(T.idKey)".lowercased() return try T.query().filter(foreignId, ident) } } diff --git a/Tests/FluentTests/ChildTests.swift b/Tests/FluentTests/ChildTests.swift index d3b74d4a..b36cd844 100644 --- a/Tests/FluentTests/ChildTests.swift +++ b/Tests/FluentTests/ChildTests.swift @@ -47,13 +47,13 @@ class Owner: Entity { } static func prepare(_ database: Fluent.Database) throws { - try database.create("Owners") { pet in + try database.create(entity) { pet in pet.id() pet.string("name") } } static func revert(_ database: Fluent.Database) throws { - try database.delete("Pets") + try database.delete(Owner.entity) } func makeNode(context: Context) throws -> Node { @@ -86,14 +86,14 @@ class Pet: Entity { } static func prepare(_ database: Fluent.Database) throws { - try database.create("Pets") { pet in + try database.create(entity) { pet in pet.id() pet.string("name") pet.parent(Owner.self, optional: false) } } static func revert(_ database: Fluent.Database) throws { - try database.delete("Pets") + try database.delete(Pet.entity) } func makeNode(context: Context) throws -> Node {