Runtime System.Exception when ContextSchemaPath is defined

Open
#552 11 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

Research direction

Start with the ContextSchemaPath behavior and the FSharp.Data.Sql.Providers.MySql.findClrType@91-1 stack-trace entry, then reproduce the database operation using the listed steps. Done means a cached schema supports design-time and compile-time use without being loaded during runtime database operations, so the insert no longer raises System.Exception: !.

Written by the indexing model from the issue text.

Description

Description

When the ContextSchemaPath locally cached schema file is defined and present, SQLProvider returns System.Exception: ! when performing database operations at runtime.

Repro steps
  1. Generate a local schema file with ContextSchemaPath as described in the documentation

  2. Debug the project

  3. Perform a database operation. The following exception is raised:

System.Exception: !
   at FSharp.Data.Sql.Providers.MySql.findClrType@91-1.Invoke(String _arg1)
   at FSharp.Data.Sql.Providers.MySql.createParam[a](String name, Int32 i, a v)
   at <StartupCode$FSharp-Data-SqlProvider>.$Providers.MySql.clo@350-280.Invoke(Tuple`2 tupledArg)
   at Microsoft.FSharp.Collections.SeqModule.Fold[T,TState](FSharpFunc`2 folder, TState state, IEnumerable`1 source)
   at FSharp.Data.Sql.Providers.MySqlProvider.createInsertCommand(IDbConnection con, StringBuilder sb, SqlEntity entity)
   at <StartupCode$FSharp-Data-SqlProvider>.$Providers.MySql.FSharp-Data-Sql-Common-ISqlProvider-ProcessUpdates@949-3.Invoke(SqlEntity e)
   at Microsoft.FSharp.Collections.SeqModule.Iterate[T](FSharpFunc`2 action, IEnumerable`1 source)
   at FSharp.Data.Sql.Providers.MySqlProvider.FSharp-Data-Sql-Common-ISqlProvider-ProcessUpdates(IDbConnection con, ConcurrentDictionary`2 entities, TransactionOptions transactionOptions, FSharpOption`1 timeout)
   at <StartupCode$FSharp-Data-SqlProvider>.$SqlRuntime.DataContext.f@1-69(SqlDataContext __, IDbConnection con, Unit unitVar0)
   at FSharp.Data.Sql.Runtime.SqlDataContext.FSharp-Data-Sql-Common-ISqlDataContext-SubmitPendingChanges()
   at MyProject.DoDatabaseStuff(DbRow _row) in C:\Users\Me\Code\MyProject\Db.fs:line 65
Stopped due to error
Expected behavior

The type provider should not attempt to load the ContextSchemaPath at runtime since it is not a data source and will never work. It should only load at design-time and compile-time to allow development and compilation (build server) without a full-time database connection.

Known workarounds

Workarounds are to either not use the ContextSchemaPath at all, or delete the cached schema file each time debugging is needed.

Related information
  • Used database: MySQL 5.6
  • Operating system Window 10 version 1803
  • Branch: 1.1.42
  • .NET Runtime: 4.5.2
  • Performance information, links to performance testing scripts : N/A
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

Similar issues

More Databases issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.