Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Postgres: Fix copy with same name in multiple tables #3297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ package app.cash.sqldelight.dialects.postgresql.grammar.mixins
import app.cash.sqldelight.dialects.postgresql.grammar.psi.PostgreSqlCopyStdin
import com.alecstrong.sql.psi.core.psi.QueryElement.QueryResult
import com.alecstrong.sql.psi.core.psi.SqlCompositeElementImpl
import com.alecstrong.sql.psi.core.psi.SqlTableName
import com.intellij.lang.ASTNode
import com.intellij.psi.PsiElement

internal abstract class CopyMixin(node: ASTNode) : SqlCompositeElementImpl(node), PostgreSqlCopyStdin {
override fun queryAvailable(child: PsiElement): Collection<QueryResult> {
val tables = tablesAvailable(child)
return tables.map {
it.query
}
val tableName = child.parent.children.filterIsInstance<SqlTableName>().single()
return tableAvailable(child, tableName.name)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ CREATE TABLE person (
name TEXT NOT NULL
);

CREATE TABLE group (
name TEXT NOT NULL
);

COPY person (name)
FROM STDIN
(
Expand Down