Skip to content
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

SimpleRepository does not correctly generate table on SqlServer with Int64 Columns #267

Open
feihtthief opened this issue Jun 16, 2011 · 1 comment

Comments

@feihtthief
Copy link

Below is a program demonstrating the bug(s) (Sorry, I also posted this in templates, as that is where the link from the wiki lands)

Step to reproduce:
Run Program to induce bug.
Expected Result:
Both columns for ID and RefID to be created as bigint columns.
Actual Result:
They are created as int columns

Additional Steps:
Change column Types to Bigint in Database. Rerun Program
Expected Result:
Expect the columns For ID and RefIT would be left as bigint.
Actual Result:
ID Column remained bigint, but RefID migrated back to int.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SubSonic.DataProviders;
using SubSonic.Repository;
using SubSonic.SqlGeneration.Schema;

namespace DemoInt64Bug
{
    [SubSonicTableNameOverride("Demos")]
    public class Demo
    {
        [SubSonicPrimaryKey]
        public long ID { get; set; }
        public long RefID { get; set; }
        [SubSonicNullString]
        public string Name { get; set; }
    }

    class Program
    {
        static void Main(string[] args)
        {
            var provider = ProviderFactory.GetProvider(@"Data Source=.\sqlexpress;Integrated Security=true;Initial Catalog=Tinker;", "System.Data.SqlClient");
            var repo = new SimpleRepository(provider, SimpleRepositoryOptions.RunMigrations);

            var demo = new Demo{Name = "foo"}; 
            repo.Add(demo); 
            // This works, but creates table with two int columns instead of two bigint columns
            // Also, if you change the columns to bigint, the next migration will turn the second column back to int, but not the first ?!?

            Int64 id = demo.ID;
            var demoBack = repo.Single<Demo>(id); // fails, and spews a error message about sqlite, but that error would be the opposite direction :S
        }
    }
}
@feihtthief
Copy link
Author

I see a problem in SubSonic.Core\DataProviders\SqlServer\Sql2005Schema.cs in the method
public override string GetNativeType(DbType dbType)
It is returning "int" for all the integer types, but it should return "bigint" for the Int64 and UInt64 Types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant