Columns with similar names on the DB collide in SQLProvider

Open
#599 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
30/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
fsharp, sql
Domain
databases

Research direction

Start by reproducing the collision in SQLProvider against SQL Server 2012 using columns named ExampleColumn, ExampleColumn:, and ExampleColumn_. Trace how the provider maps those database columns to F# identifiers. Done means the table can be queried without indistinct generated names, while preserving a usable way to reference every column.

Written by the indexing model from the issue text.

Description

Description

When a table has 2 or more columns whose names are only different by "special" characters, SQLProvider creates indistinct mappings for them.

Repro steps
  1. Create a table with these columns
  • [ExampleColumn]
  • [ExampleColumn:]
  • [ExampleColumn_]
  1. Try to query this table from SQLProvider
Expected behavior

I would expect, given F#'s ability to create identifiers with special characters, that SQLProvider wouldn't need to alter your column names in any way (at least, as an option when creating the provider).

Actual behavior

SQLProvider will rename these fields with indistinct names, causing an exception to be thrown, and the table becomes un-queryable.

Known workarounds

Create a view in your database that disambiguates that column names and use that from SQLProvider, but this is not acceptable since you're then designing the database around an arbitrary tool in a separate code stack.

Related information
  • SQL Server 2012
  • Windows 7, SP1
  • v1.1.30-1.1.58
  • .NET 4.6
Dominant language
F#
Stars
627
Forks
147
Avg merge
2h 2m
Merged PRs (30d)
1

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from fsprojects/SQLProvider

All issues in fsprojects/SQLProvider

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.