question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incorrect Oracle create table generation if a table includes Guid

See original GitHub issue

CreateTable<T> generates invalid CREATE TABLE statement if a table has a Guid column without an explicit DB type when Oracle provider is being used.

    [Table("Calculation")]
    public class Calculation
    {
        /// <summary>The Id</summary>
        [Column, Identity, PrimaryKey, NotNull]
        public int Id { get; set; }
        /// <summary>Client request id</summary>
        [Column, NotNull]
        public Guid RequestId { get; set; }
    }

Resulting sql:

CREATE TABLE pfe.Calculation
(
	Id           Int        NOT NULL,
	RequestId    Guid       NOT NULL,
	Status       Int        NOT NULL,
	PathCount    Int        NOT NULL,
	StartDate    timestamp  NOT NULL,
	TimeHorizon  Float      NOT NULL,
	FactorListId Int        NOT NULL,
	Created      timestamp  NOT NULL,
	Updated      timestamp  NOT NULL,

	CONSTRAINT PK_Calculation PRIMARY KEY (Id)
)

Oracle does not have the Guid column type. It should be raw(16). An addition of DataType = DataType.Binary, Length = 16 to the column attribute does not help also. After it the generated column type is Binary(16) which is also invalid. The only obvious way to workaround the problem is to set DbType=“Raw(16)” property of the Column attribute.

Environment details

linq2db version: 1.8.2
Database Server: Oracle 11g
Database Provider: Oracle.Managed
Operating system: Windows 7
Framework version: .NET Framework 4.6.2

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
Lexeycommented, Jun 23, 2017

May be better to keep it and add proper default mappings later.

1reaction
ilicommented, Jun 21, 2017

About second issue this should help:

        [Column(DataType = DataType.VarBinary, Length = -1), NotNull]
        [Column(DataType = DataType.Blob, Configuration = DataProviderName.Oracle)]
        public byte[] Data { get; set; }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Creating a Table
Purpose. Use the CREATE TABLE statement to create one of the following types of tables: A relational table, which is the basic structure...
Read more >
How to Use Create Table, Alter Table, and Drop Table in ...
An introduction to the create table, alter table, and drop table commands in Oracle Database. Use these to create, change, and remove ...
Read more >
Specifying Partitioning When Creating Tables and Indexes
Oracle Database Object-Relational Developer's Guide for information specific to creating tables with object types, nested tables, or VARRAYs.
Read more >
ORA-00900: invalid SQL statement
Cause: The datatype entered in the CREATE or ALTER TABLE statement is not valid. Action: Correct the syntax. Cause: A table or cluster...
Read more >
Alter Table
Purpose. Use the ALTER TABLE statement to alter the definition of a nonpartitioned table, a partitioned table, a table partition, or a table...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found