Coder Social home page Coder Social logo

shaolinq's People

Contributors

asizikov avatar dependabot[bot] avatar jeffgos avatar maverik avatar samcook avatar tumtumtum avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

shaolinq's Issues

AsyncRewriter fails when used on expression body method

Steps to reproduce:

  • Create class library project targeting .NET 4.6
  • Install Shaolinq.AsyncRewriter 1.1.1.989
  • Create new class:
    public partial class Class1
    {
        [RewriteAsync]
        public int Foo() => 10;
    }
  • Try to build the project

This will produce an invalid C# code in GeneratedAsync.cs file:

namespace ClassLibrary3
{
#pragma warning disable
    using System;
    using System.Threading;
    using System.Threading.Tasks;
    using global::ClassLibrary3;

    public partial class Class1
    {
        public Task<int> FooAsync()
        {
            return FooAsync(CancellationToken.None);
        }

        => 10;
        public async Task<int> FooAsync(CancellationToken cancellationToken) => 10;
    }
}

PostgreSQL and timestamp

Hi,

I'm evaluating Shaolinq hoping to replace our npgsql-only implementation, to get real ORM and support for Linq, and so far I really like it!

I do have an issue when I insert new item with a timestamp (without timezone) column, the time ending up in the db is UTC (currently one hour off for me in Sweden). In the docs for npgsql (http://www.npgsql.org/doc/datetime.html) you can see that they don't touch the DateTime when the column is timestamp, but Shaolinq seems to always change it to UTC (see UniversalTimeNormalisingDateTimeSqlDateType.cs).
Is that really a correct behavior?

Thanks!
/Roger

ForUpdate behaviour

How should ForUpdate work (with Postgres specifically)?

This works as expected:
dataModel.Categories.Where(x => x.Id == categoryId).ForUpdate().ToList().First();

SELECT "T0"."CategoryId", "T0"."Name"
FROM "Category" AS "T0"
WHERE (("T0"."CategoryId") = ('28ac0432-a4ca-409b-9c9c-510e7d917d93')) FOR UPDATE

These don't:
dataModel.Categories.ForUpdate().Where(x => x.Id == categoryId).ToList().First();

SELECT "T0"."CategoryId", "T0"."Name"
FROM "Category" AS "T0"
WHERE (("T0"."CategoryId") = ('28ac0432-a4ca-409b-9c9c-510e7d917d93'))

dataModel.Categories.Where(x => x.Id == categoryId).ForUpdate().First(); or
dataModel.Categories.ForUpdate().First(x => x.Id == categoryId);

SELECT "T0"."CategoryId", "T0"."Name"
FROM "Category" AS "T0"
WHERE (("T0"."CategoryId") = ('28ac0432-a4ca-409b-9c9c-510e7d917d93')) LIMIT 1

GroupBy seems messed up (and do these ever get responded to?)

This query:
var salesTotals =
_postgresDataAccessModel.ItemSales.Where(
sales => sales.CompanyId == companyId && sales.LocationId == locationId &&
sales.ItemType == "Tap" &&
sales.DateSold >= adjustedStartTime && sales.DateSold <= endDate)
.GroupBy(sales => new {sales.MenuItemProductId, sales.DisplaySize})
.Select(sales => new
{
sales.Key.MenuItemProductId,
sales.Key.DisplaySize,
quantity = sales.Count()
}).ToList();

(over about 5000 records)
Takes two minutes to run in Shaolinq, and about 5 seconds in PGAdmin

Scope classes missing

I added Shaolinq postgres to my project. (its .net 4.5.2).,
I have the PostgresConfiguration and DataAccessModel classes but for some reason no DataAccessScope or TransactionScope classes. :/

Shaolinq.Sqlite wrong dependency

I installed Shaolinq and Shaolinq.Sqlite through NPM. The last version "1.1.1.989" installs System.Data.Sqlite 1.0.103.0.
When this insruction :
var model = DataAccessModel.BuildDataAccessModel(configuration);
is about to be executed the debugger says that "System.Data.Sqlite 1.0.102.0" could not be found.
I forced the uninstall of version "1.0.103.0" and installed MSIL version 1.0.102 witch is deprecated. Now it gives me an ArgumentNullException on the same instruction.
Any suggestions would be greatly appreciated.

SelectForUpdate missing. PrimaryKey attribute doesn't work

I'm decorating a property with the PrimaryKey attribute but I still get an error saying a Primary key is missing (it is still looking for Table Name + Id)

You're documentation shows a SelectForUpdate to do bulk updates, but it does not appear to be available

CreateDatabaseAndSchema does not honour PostgresSqlDatabaseContextInfo.SchemaName

First of all, I just discovered your ORM an hour back, and want to thank you for creating something that worked with postgresql out of the box. Right now I can't even get Npgsql.EntityFramework to do that (ticket open on their site).

Now for the actual problem:

This may be a specific implementation issue, but I'm trying to work with custom schema name where all the new tables should reside and I keep getting exception that the schema doesn't exist (which is perfectly fine since it just created fresh database).

Having a browser through relevant source, I've concluded that we basically need to override this in PostgresSharedSqlDatabaseSchemaManager and create the schema explicitly and then proceed with base CreateSchema which assumes that the relevant schema name is already there.

I'll keep digging on how to fix this for a bit (pointers welcome!).

Timestamps

Hey, im new on .net dev
but i write some app, sites... in php using laravel. and this have a nice orm like this.

a nice function of eloquent is "timestamps"
Timestamps
By default, Eloquent expects created_at and updated_at columns to exist on your tables.

every new item is added a created_at time, and update populate column updated_at.

is possible to implement.

another function is SoftDelete.

nice working

tnk's
[]'s

AsyncRewriter generates invalid code within a lock

AsyncRewriter inserts async method calls inside code that is within a lock section, however this won't compile (Cannot await in the body of a lock statement):

lock (lockObj)
{
    // can't do this inside a lock
    await this.MethodAsync(cancellationToken).ConfigureAwait(false);
}

Can be worked around by using something like SemaphoreSlim instead:

await semaphoreSlim.WaitAsync();
try
{
    // synchronised code here
}
finally
{
    semaphoreSlim.Release();
}

CASCADE action not supported for Postgres

Hello,

It seems that CASCADE foreign key action is not supported at all. Is this by design or is this a bug?

There's a method FixAction(SqlColumnReferenceAction action) in the

D:\Dev\Shaolinq\src\Shaolinq\Persistence\Linq\SqlDataDefinitionExpressionBuilder.cs file that checks if the current Sql dialect supports Restrict when one tries to apply Cascade:

case SqlColumnReferenceAction.Cascade:
            return this.sqlDialect.SupportsCapability(SqlCapability.RestrictAction) ? SqlColumnReferenceAction.Restrict : SqlColumnReferenceAction.NoAction;

Restrict is not enabled for Postgres. Postgres does support cascade actions for foreign key constraints.

Add a fallback for Column recommended lenght for enum fields

When I have a DataAcsessObject with enum property, and property has no values defined:

   [DataAccessObject]
   public abstract class DbType : DataAccessObject<Guid>
   {
        [PersistedMember]
        public abstract Enum? EnumMember { get; set; }
   }

    public enum Enum
    {
            // No values defined here!
    }

Shaolinq is trying to guess the size of the column and fails with the following exception:

XXX : System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation.
  ----> System.InvalidOperationException : Sequence contains no elements
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at System.Activator.CreateInstance(Type type, Object[] args)
   at Shaolinq.Persistence.DefaultSqlDataTypeProvider.GetEnumDataType(Type type)
   at Shaolinq.Persistence.DefaultSqlDataTypeProvider.GetSqlDataType(Type type)
   at Shaolinq.Persistence.Linq.SqlDataDefinitionExpressionBuilder.BuildColumnDefinition(ColumnInfo columnInfo)
   at Shaolinq.Persistence.Linq.SqlDataDefinitionExpressionBuilder.BuildCreateTableExpression(TypeDescriptor typeDescriptor)
   at Shaolinq.Persistence.Linq.SqlDataDefinitionExpressionBuilder.Build()
   at Shaolinq.Persistence.SqlDatabaseSchemaManager.BuildDataDefinitonExpressions(DatabaseCreationOptions options)
   at Shaolinq.Persistence.SqlDatabaseSchemaManager.CreateDatabaseAndSchema(DatabaseCreationOptions options)
   at Shaolinq.DataAccessModel.Create(DatabaseCreationOptions options)
   at Namespace.Class.MethodName() in path/to/class.cs:line 34
--InvalidOperationException
   at System.Linq.Enumerable.Max(IEnumerable`1 source)
   at Shaolinq.Persistence.DefaultStringEnumSqlDataType`1.GetRecommendedLength(Type enumType)
   at Shaolinq.Persistence.DefaultStringEnumSqlDataType`1.CreateConstraintDefaults(ConstraintDefaultsConfiguration defaultsConfiguration, Type type)
   at Shaolinq.Persistence.DefaultStringEnumSqlDataType`1..ctor(ConstraintDefaultsConfiguration constraintDefaultsConfiguration)

That would be nice to have a more descriptive error message here, or use a fallback value for RecommendedLength.

I can't find any documentation

Despite numerous Google searches, I can't seem to find any documentation.

So I have downloaded and installed Shaolinq, and am ready to get started writing code. But I have no idea what to write in order to create classes that ShaoLinq will understand, how to get ShaoLinq to create a database to match those classes, how to create, update, delete and retrieve objects, or anything.

Surely there must be some instructions somewhere, but I can't find them!

Conditional indices

By default, Shaolinq generates an index with a NOT NULL condition on each of the columns included in the index, e.g.:

CREATE UNIQUE NONCLUSTERED INDEX [Person_IsAdult_Name] ON [dbo].[Person] ([Name], [IsAdult]) WHERE ([Name] IS NOT NULL AND [IsAdult] IS NOT NULL)

But sometimes we might don't want the IS NOT NULL conditions at all, e.g.:

CREATE UNIQUE NONCLUSTERED INDEX [Person_IsAdult_Name] ON [dbo].[Person] ([Name], [IsAdult])

In other cases, we might want to be able to specify some specific NOT NULL conditions, e.g.:

CREATE UNIQUE NONCLUSTERED INDEX [Person_IsAdult_Name] ON [dbo].[Person] ([Name], [IsAdult]) WHERE ([Name] IS NOT NULL)

And in other cases, we need to be able to specify a totally different condition, e.g.:

CREATE UNIQUE NONCLUSTERED INDEX [Person_IsAdult_Name] ON [dbo].[Person] ([Name], [IsAdult]) WHERE ([Name] IS NOT NULL AND [IsAdult] = 1)

Would it be possible to implement this type of flexibility via the [Index] attribute in Shaolinq?

Object should be inserted into cache before it is initialized

At the moment an object is submitted to the cache only after it has been member initalised. Performance can be improved by submitting an object to the cache in case any of its members or members members reference itself because the partially constructed reference should be used.

Default constraint does not add space between constraint & value

Haven't had any success in figuring this out yet, so thought I'll open an issue. If i manage to figure it out, i'll send a pull for it.

I can see that it's likely happening from Sql92QueryFormatter but even when i give it space in formatter, it still doesn't get picked up. Will try to investigate more tomorrow.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.