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

PostgresSql中,能否增加 些初始个性化处理 #1248

Closed
lxh023 opened this issue Sep 18, 2022 · 5 comments
Closed

PostgresSql中,能否增加 些初始个性化处理 #1248

lxh023 opened this issue Sep 18, 2022 · 5 comments

Comments

@lxh023
Copy link

lxh023 commented Sep 18, 2022

Feature 特性

PostgresSql中,能否进行个性化配置(能指定默认表空间及索引空间、模式等等),在FreeSqlBuilder中指定

简要描述原因

1、 在实际开发中,出于数据安全及空间规划考虑,postgreSql不可能直接用默认的public模式,系统默认表空间,需要指定特定模式及表空间。一两张表还好,如果多张表就需要在数据库里手工更改或表迁移,就显得繁琐。如果能在FreeSqlBuilder就指定好就省却后续处理
2、插表中,对于表中,对于日期型的可空字段,freesql 会插入0001-01-01 00:00:00,而Oracle会插入null ,能否在PostgreSql也这样实现,毕竟从Oracle转到PostgreSql,对这一点还不大习惯

使用场景

面向postgresql 的codefirst开发及生产库的初始建表

@lxh023
Copy link
Author

lxh023 commented Sep 19, 2022

插表中,对于表中,对于日期型的可空字段,freesql 会插入0001-01-01 00:00:00

这个搞定了,只需要在fluentApi中设定.InsertValueSql("null")就可以了,现在的需求是,能否指定默认表空间及索引空间?

@2881099
Copy link
Collaborator

2881099 commented Sep 19, 2022

如果 fsql.CodeFirst.GetComparisonDDLStatements<Topic>() 获取创建的 DDL string 内容,再处理 string 会不会很 low

@2881099 2881099 closed this as completed Oct 2, 2022
@lxh023
Copy link
Author

lxh023 commented May 16, 2023

不会,哈哈,先用。具体怎么用呢?

@lxh023
Copy link
Author

lxh023 commented May 16, 2023

插表中,对于表中,对于日期型的可空字段,freesql 会插入0001-01-01 00:00:00

这个搞定了,只需要在fluentApi中设定.InsertValueSql("null")就可以了,现在的需求是,能否指定默认表空间及索引空间?

发现对于DateTime?的字段在MapType(typeof(DateTIme)下,.IsNull(true).InsertValueSql("null") 是没效果的,必须是在 DbType="timestamp(6)",在null情况下才起效果。

@2881099
Copy link
Collaborator

2881099 commented May 16, 2023

  1. public 模式
fsql.Aop.ConfigEntity += (_, e) => {
    e.ModifyResult.Name = $"xxx.{e.ModifyResult.Name}";
};
  1. 默认值插入问题
fsql.Aop.AuditValue += (_, e) => {
    if (e.AuditValueType == AuditValueType.Insert &&
        e.Column.CsType == typeof(DateTime) && (DateTime)e.Value < new DateTime(1970, 1, 1))
        e.Value = new DateTime(1970, 1, 1);
};

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

2 participants