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

UnitTest Fixed. #202

Merged
merged 37 commits into from
Apr 20, 2022
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
19bf3a4
fixed. 修复CUD模块中自动生成的SQL语句,在Oracle下提示ORA-00933命令未正确结束的错误。原因是SQL语句结束处,加…
gmij Mar 10, 2022
11a40b3
Merge branch 'dotnetcore:master' into master
gmij Apr 8, 2022
bf71f5b
fixed. 当使用CUD模块,没有xml配置项时,会导致缓存无法开启。移除对SqlMaps的缓存配置项检查。
gmij Apr 8, 2022
25ef2f6
移除注释的代码。
gmij Apr 8, 2022
73261f8
Merge branch 'dotnetcore:master' into master
gmij Apr 8, 2022
50628f3
Merge branch 'dotnetcore:master' into master
gmij Apr 8, 2022
36498c4
动态插入时,自动生成Statement配置信息。
gmij Apr 8, 2022
20e5b9c
Merge branch 'master' of https://github.com/gmij/SmartSql
gmij Apr 8, 2022
56b07bf
fixed. CUD,在执行时,把Statement加入到内存中,已能和缓存产生完整交互。
gmij Apr 8, 2022
f9615d3
1. 优化CUDStatement的默认名称的引用
gmij Apr 8, 2022
96da01f
优化Statement的使用。
gmij Apr 8, 2022
38b4c8d
add. CUD statement build
gmij Apr 11, 2022
5f611ef
commit unit test
gmij Apr 11, 2022
7d61e43
优化sql生成过程
gmij Apr 12, 2022
a19ec72
完善insert和update的语法构成方式。
gmij Apr 12, 2022
9c05d36
fix. insert and update CUD invalid.
gmij Apr 12, 2022
c0a4144
移除过期的代码。
gmij Apr 12, 2022
e1aebfe
add. DyRepository缓存加载
gmij Apr 13, 2022
155de18
合并变更
gmij Apr 13, 2022
433684b
合并,解决冲突
gmij Apr 13, 2022
c42a05e
fixed. CUD模块和动态仓储模块同时启用时,动态仓储上设置同名Statement时,缓存不生效。
gmij Apr 13, 2022
7d20dd7
merge commited.
gmij Apr 13, 2022
ddc3556
Merge branch 'dotnetcore:cud-statement' into cud-statement
gmij Apr 14, 2022
be6dd3c
fix. 调通部分单元测试。修改数据库初始化脚本及部分测试模型
gmij Apr 14, 2022
46d7e9e
Merge branch 'cud-statement' of https://github.com/gmij/SmartSql into…
gmij Apr 14, 2022
b8957e9
优化sql in语法的匹配表达式
gmij Apr 14, 2022
ab9a917
fixed. 完善DeleteMany的代码。并通过单元测试
gmij Apr 14, 2022
d3f43eb
完善单元测试用例
gmij Apr 14, 2022
e45aadf
完善单元测试
gmij Apr 14, 2022
1af77df
完善单元测试
gmij Apr 14, 2022
4687cd3
完善测试需求
gmij Apr 14, 2022
74a14d2
完善单元测试
gmij Apr 14, 2022
970ad5a
Merge branch 'dotnetcore:cud-statement' into cud-statement
gmij Apr 15, 2022
5623b8d
Merge branch 'dotnetcore:cud-statement' into cud-statement
gmij Apr 17, 2022
7e44098
fixed. InsertReturnId and DeleteMany statement Build method errors.
gmij Apr 17, 2022
0c7bac0
fixed. test unit bugs.
gmij Apr 19, 2022
7d81480
变更数据源。
gmij Apr 19, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/SmartSql.Test.Unit/CUD/CUDTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ public void Get()
Assert.NotNull(entity);
}

[Fact]
public void GetWithPropertyTrack()
{
AllPrimitive insertEntity = InsertReturnIdImpl(out long id);
var entity = SqlMapper.GetById<AllPrimitive, long>(id, true);
Assert.NotNull(entity);
}

[Fact]
public void Insert()
{
Expand Down
2 changes: 1 addition & 1 deletion src/SmartSql.Test.Unit/DI/DITest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private void GetSmartSqlService(IServiceProvider serviceProvider)
var dbSessionFactory = serviceProvider.GetRequiredService<IDbSessionFactory>();
}

protected String ConnectionString => "Data Source=.;Initial Catalog=SmartSqlTestDB;Integrated Security=True";
protected String ConnectionString => "Data Source=.;Initial Catalog=SmartSqlStarterDB;Integrated Security=True";
gmij marked this conversation as resolved.
Show resolved Hide resolved

[Fact]
public void AddSmartSqlByFunc()
Expand Down
4 changes: 2 additions & 2 deletions src/SmartSql.Test.Unit/Deserializer/EntityDeserializerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void QuerySingle()
var entity = SqlMapper.QuerySingle<AllPrimitive>(new RequestContext
{
Scope = nameof(AllPrimitive),
SqlId = "GetEntity",
SqlId = "GetById",
Request = new { Id = id }
});
Assert.Equal(id, entity.Id);
Expand Down Expand Up @@ -58,7 +58,7 @@ public async Task QuerySingleAsync()
var entity = await SqlMapper.QuerySingleAsync<AllPrimitive>(new RequestContext
{
Scope = nameof(AllPrimitive),
SqlId = "GetEntity",
SqlId = "GetById",
Request = new { Id = id }
});
Assert.Equal(id, entity.Id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ public class EntityMetaDataCacheTypeTest
public void GetTableName()
{
var tableName = EntityMetaDataCacheType.GetTableName(typeof(AllPrimitive));
Assert.Equal("AllPrimitive", tableName);
Assert.Equal("T_AllPrimitive", tableName);
}
}
76 changes: 57 additions & 19 deletions src/SmartSql.Test.Unit/init-db.sql
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
create database if not exists SmartSqlStarterDB;
use SmartSqlStarterDB;
create database SmartSqlTestDB;

create table if not exists T_AllPrimitive
use SmartSqlTestDB;

create table T_AllPrimitive
(
Id bigint not null AUTO_INCREMENT primary key,
Boolean boolean not null,
`Char` char(1) not null,
Id bigint auto_increment
primary key,
Boolean tinyint(1) not null,
`Char` char not null,
Int16 mediumint not null,
Int32 int not null,
Int64 bigint not null,
Expand All @@ -16,17 +18,53 @@ create table if not exists T_AllPrimitive
Guid char(36) not null,
TimeSpan time not null,
NumericalEnum tinyint(1) not null,
NullableBoolean boolean,
NullableChar char(1),
NullableInt16 mediumint,
NullableInt32 int,
NullableInt64 bigint,
NullableSingle float,
NullableDecimal decimal,
NullableDateTime datetime,
NullableGuid char(32),
NullableTimeSpan time,
NullableNumericalEnum tinyint(1),
NullableString varchar(100)
) engine = InnoDB;
NullableBoolean tinyint(1) null,
NullableChar char null,
NullableInt16 mediumint null,
NullableInt32 int null,
NullableInt64 bigint null,
NullableSingle float null,
NullableDecimal decimal null,
NullableDateTime datetime null,
NullableGuid char(36) null,
NullableTimeSpan time null,
NullableNumericalEnum tinyint(1) null,
NullableString varchar(100) null
) engine = InnoDb
;

create table t_column_annotation_entity
(
id bigint auto_increment
primary key,
name varchar(100) not null,
extend_data longtext collate utf8mb4_bin not null,
constraint extend_data
check (json_valid(`extend_data`))
) engine = InnoDb
;

create table T_User
(
Id bigint auto_increment
primary key,
UserName varchar(50) not null,
Status tinyint(2) not null
);

create table T_UserExtendedInfo
(
UserId bigint auto_increment
primary key,
Data json not null
);



# Create PROCEDURE SP_Query(out Total int)
#
# BEGIN
# Select Count(*) into Total From T_AllPrimitive T;
# SELECT T.* From T_AllPrimitive T limit 10;
# END
# ;
4 changes: 2 additions & 2 deletions src/SmartSql/CUD/CUDSqlGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public Statement BuildDeleteById(GeneratorParams gParams)

public Statement BuildDeleteMany(GeneratorParams gParams)
{
var sql = $"Delete From {gParams.TableName} Where {gParams.PkCol.Name} In {FormatParameterName(_provider, gParams.PkCol.Name)}";
var sql = $"Delete From {gParams.TableName} Where {gParams.PkCol.Name} In {FormatParameterName(_provider, gParams.PkCol.Name + "s")}";
return BuildStatement(CUDStatementName.DeleteMany, sql, gParams.Map);
}

Expand Down Expand Up @@ -113,7 +113,7 @@ public Statement BuildInsertReturnId(GeneratorParams arg)
}
else
{
statement.SqlTags.Add(new SqlText($"; {_provider.SelectAutoIncrement};", _provider.ParameterPrefix));
statement.SqlTags.Add(new SqlText($"{_provider.SelectAutoIncrement}", _provider.ParameterPrefix));
}

return statement;
Expand Down