Repository: cashapp/sqldelight
Issue: Table name is mapped incorrectly

**Build Environment**
SQLDelight version: 1.5.0
OS: Android
Gradle version: 4.2.1
Kotlin version: 1.5.10

**Describe the bug**
The bug happens when:
* Using SQLDelight 1.5.0
Or
* Using SQLDelight 1.4.4 + adding `classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$versions.navigation"`

I have a table `annotation`:
```
CREATE TABLE annotation (
  id INTEGER NOT NULL PRIMARY KEY,
  name TEXT
);

insertAnnotation:
INSERT INTO annotation
VALUES ?;
```

In `DatabaseImpl.kt` for the parameter of methods `annotation_` is used  instead of `annotation`, but only for the method-arguments, not when actually accessed and thus I get `Unresolved reference: annotation`:
```
  public override fun insertAnnotation(annotation_: Annotation_): Unit {
    driver.execute(461624073, """
    |INSERT INTO annotation
    |VALUES (?, ?)
    """.trimMargin(), 2) {
      bindLong(1, annotation.id)
      bindString(2, annotation.name)
    }
    notifyQueries(461624073, {database.positionMarkerQueries.selectAll +
        database.positionMarkerQueries.selectUsedAnnotationsForMap})
  }
  ```
  
 Has `Annotation` becomed a reserved keyword (since it is suddenly mapped to `Annotation_`)? In any case the mapping has to be applied to the method-body as well.
  




Changed files:
sqldelight-compiler/src/main/kotlin/com/squareup/sqldelight/core/compiler/model/BindableQuery.kt
sqldelight-compiler/src/test/kotlin/com/squareup/sqldelight/core/queries/MutatorQueryFunctionTest.kt

diff --git a/sqldelight-compiler/src/main/kotlin/com/squareup/sqldelight/core/compiler/model/BindableQuery.kt b/sqldelight-compiler/src/main/kotlin/com/squareup/sqldelight/core/compiler/model/BindableQuery.kt
index 3bfd3b5c9..1928f30fe 100644
--- a/sqldelight-compiler/src/main/kotlin/com/squareup/sqldelight/core/compiler/model/BindableQuery.kt
+++ b/sqldelight-compiler/src/main/kotlin/com/squareup/sqldelight/core/compiler/model/BindableQuery.kt
@@ -71,7 +71,7 @@ abstract class BindableQuery(
           index + 1,
           (column.columnType as ColumnTypeMixin).type().let {
             it.copy(
-              name = "${statement.tableName.name}.${it.name}",
+              name = "${allocateName(statement.tableName)}.${it.name}",
               extracted = true
             )
           }
diff --git a/sqldelight-compiler/src/test/kotlin/com/squareup/sqldelight/core/queries/MutatorQueryFunctionTest.kt b/sqldelight-compiler/src/test/kotlin/com/squareup/sqldelight/core/queries/MutatorQueryFunctionTest.kt
index d61c4172d..c7536100d 100644
--- a/sqldelight-compiler/src/test/kotlin/com/squareup/sqldelight/core/queries/MutatorQueryFunctionTest.kt
+++ b/sqldelight-compiler/src/test/kotlin/com/squareup/sqldelight/core/queries/MutatorQueryFunctionTest.kt
@@ -134,8 +134,8 @@ class MutatorQueryFunctionTest {
       |  |INSERT INTO data
       |  |VALUES (?, ?)
       |  ""${'"'}.trimMargin(), 2) {
-      |    bindLong(1, data.id)
-      |    bindString(2, data.value?.let { database.data_Adapter.valueAdapter.encode(it) })
+      |    bindLong(1, data_.id)
+      |    bindString(2, data_.value?.let { database.data_Adapter.valueAdapter.encode(it) })
       |  }
       |}
       |""".trimMargin()
@@ -202,8 +202,8 @@ class MutatorQueryFunctionTest {
       |  |INSERT INTO data
       |  |VALUES (?, ?)
       |  ""${'"'}.trimMargin(), 2) {
-      |    bindLong(1, data.id)
-      |    bindString(2, data.value?.let { database.data_Adapter.valueAdapter.encode(it) })
+      |    bindLong(1, data_.id)
+      |    bindString(2, data_.value?.let { database.data_Adapter.valueAdapter.encode(it) })
       |  }
       |}
       |""".trimMargin()
@@ -235,7 +235,7 @@ class MutatorQueryFunctionTest {
       |  |INSERT INTO data (id)
       |  |VALUES (?)
       |  ""${'"'}.trimMargin(), 1) {
-      |    bindLong(1, data.id)
+      |    bindLong(1, data_.id)
       |  }
       |}
       |""".trimMargin()
@@ -505,4 +505,37 @@ class MutatorQueryFunctionTest {
     |""".trimMargin()
     )
   }
+
+  @Test fun `kotlin keywords are mangled in parameters and arguments inside insert stmt`() {
+    val file = FixtureCompiler.parseSql(
+      """
+      |CREATE TABLE annotation (
+      |  id INTEGER NOT NULL PRIMARY KEY,
+      |  name TEXT
+      |);
+      |
+      |insertAnnotation:
+      |INSERT INTO annotation
+      |VALUES ?;
+    """.trimMargin(),
+      tempFolder, fileName = "Data.sq"
+    )
+
+    val mutator = file.namedMutators.first()
+    val generator = MutatorQueryGenerator(mutator)
+
+    assertThat(generator.function().toString()).isEqualTo(
+      """
+      |public override fun insertAnnotation(annotation_: com.example.Annotation_): kotlin.Unit {
+      |  driver.execute(${mutator.id}, ""${'"'}
+      |  |INSERT INTO annotation
+      |  |VALUES (?, ?)
+      |  ""${'"'}.trimMargin(), 2) {
+      |    bindLong(1, annotation_.id)
+      |    bindString(2, annotation_.name)
+      |  }
+      |}
+      |""".trimMargin()
+    )
+  }
 }