@@ -10,24 +10,25 @@ import SwiftSyntax
1010import SwiftSyntaxBuilder
1111
1212public protocol Language {
13- static func queryTypeName ( input : String , output : String ) -> String
13+ init ( options : GenerationOptions )
1414
15- static func inputTypeName ( input: BuiltinOrGenerated ? ) -> String
15+ func queryTypeName ( input: String , output : String ) -> String
1616
17- static func outputTypeName(
17+ func inputTypeName( input: BuiltinOrGenerated ? ) -> String
18+
19+ func outputTypeName(
1820 output: BuiltinOrGenerated ? ,
1921 cardinality: Cardinality
2022 ) -> String
2123
2224 /// Returns the Language builtin for the given SQL type
23- static func builtinType( for type: Type ) -> String
25+ func builtinType( for type: Type ) -> String
2426
2527 /// A file source code containing all of the generated tables, queries and migrations.
26- static func file(
28+ func file(
2729 migrations: [ String ] ,
2830 tables: [ GeneratedModel ] ,
29- queries: [ ( String ? , [ GeneratedQuery ] ) ] ,
30- options: GenerationOptions
31+ queries: [ ( String ? , [ GeneratedQuery ] ) ]
3132 ) throws -> String
3233
3334 /// Function to generate a interpolation segment in a string
@@ -38,27 +39,25 @@ public protocol Language {
3839 /// ```swift
3940 /// \(input.sqlQuestionMarks)
4041 /// ```
41- static func interpolatedQuestionMarks( for param: String ) -> String
42+ func interpolatedQuestionMarks( for param: String ) -> String
4243}
4344
4445extension Language {
45- public static func generate(
46+ public func generate(
4647 migrations: [ String ] ,
4748 queries: [ ( String ? , [ Statement ] ) ] ,
48- schema: Schema ,
49- options: GenerationOptions
49+ schema: Schema
5050 ) throws -> String {
5151 let values = try assemble ( queries: queries, schema: schema)
5252
5353 return try file (
5454 migrations: migrations,
5555 tables: values. tables,
56- queries: values. queries,
57- options: options
56+ queries: values. queries
5857 )
5958 }
6059
61- public static func assemble(
60+ public func assemble(
6261 queries: [ ( String ? , [ Statement ] ) ] ,
6362 schema: Schema
6463 ) throws -> (
@@ -70,7 +69,7 @@ extension Language {
7069 return ( Array ( tables. values) , queries)
7170 }
7271
73- private static func query(
72+ private func query(
7473 for statement: Statement ,
7574 tables: [ Substring : GeneratedModel ]
7675 ) -> GeneratedQuery {
@@ -113,7 +112,7 @@ extension Language {
113112 )
114113 }
115114
116- private static func model( for table: Table ) -> GeneratedModel {
115+ private func model( for table: Table ) -> GeneratedModel {
117116 GeneratedModel (
118117 name: table. name. name. capitalizedFirst,
119118 fields: table. columns. reduce ( into: [ : ] ) { fields, column in
@@ -135,12 +134,12 @@ extension Language {
135134
136135 /// If the column type was aliased then this will return the `builtin`
137136 /// type for the root type of the alias.
138- private static func builtinForAliasedType( for type: Type ) -> String ? {
137+ private func builtinForAliasedType( for type: Type ) -> String ? {
139138 guard case let . alias( root, _) = type else { return nil }
140139 return builtinType ( for: root)
141140 }
142141
143- private static func inputTypeIfNeeded(
142+ private func inputTypeIfNeeded(
144143 statement: Statement ,
145144 definition: Definition
146145 ) -> BuiltinOrGenerated ? {
@@ -175,7 +174,7 @@ extension Language {
175174 return . model( model)
176175 }
177176
178- private static func outputTypeIfNeeded(
177+ private func outputTypeIfNeeded(
179178 statement: Statement ,
180179 definition: Definition ,
181180 tables: [ Substring : GeneratedModel ]
0 commit comments