Skip to content

Commit

Permalink
pivot name fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tanner0101 committed Oct 17, 2016
1 parent 5c30919 commit b85adc3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Sources/Fluent/Entity/Entity.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ public protocol Entity: Preparation, NodeConvertible {
*/
static var entity: String { get }

/**
The name to use for internal storage.

This should be left as the default
implementation except for special cases
like pivots.
*/
static var name: String { get }

/**
The entity's primary identifier.
This is the same value used for
Expand Down
4 changes: 4 additions & 0 deletions Sources/Fluent/Query/Join.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ public final class Pivot<
return "\(left.name)_\(right.name)"
}

public static var name: String {
return entity
}

public static var left: Entity.Type {
if First.entity < Second.entity {
return First.self
Expand Down

0 comments on commit b85adc3

Please sign in to comment.