Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
Efcore.Pg
提交
5316df8f
E
Efcore.Pg
项目概览
jobily
/
Efcore.Pg
12 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
Efcore.Pg
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
5316df8f
编写于
12月 22, 2021
作者:
S
Shay Rojansky
提交者:
GitHub
12月 22, 2021
1
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Multirange support for NodaTime (#2182)
Fixes #2178
上级
ed65c44c
变更
8
展开全部
隐藏空白更改
内联
并排
Showing
8 changed file
with
526 addition
and
146 deletion
+526
-146
src/EFCore.PG.NodaTime/EFCore.PG.NodaTime.csproj
src/EFCore.PG.NodaTime/EFCore.PG.NodaTime.csproj
+1
-1
src/EFCore.PG.NodaTime/Storage/Internal/DateIntervalMultirangeMapping.cs
...odaTime/Storage/Internal/DateIntervalMultirangeMapping.cs
+29
-0
src/EFCore.PG.NodaTime/Storage/Internal/DateIntervalRangeMapping.cs
....PG.NodaTime/Storage/Internal/DateIntervalRangeMapping.cs
+11
-8
src/EFCore.PG.NodaTime/Storage/Internal/IntervalMultirangeMapping.cs
...PG.NodaTime/Storage/Internal/IntervalMultirangeMapping.cs
+29
-0
src/EFCore.PG.NodaTime/Storage/Internal/IntervalRangeMapping.cs
...Core.PG.NodaTime/Storage/Internal/IntervalRangeMapping.cs
+26
-13
src/EFCore.PG.NodaTime/Storage/Internal/NpgsqlNodaTimeTypeMappingSourcePlugin.cs
...Storage/Internal/NpgsqlNodaTimeTypeMappingSourcePlugin.cs
+95
-9
src/EFCore.PG/Storage/Internal/Mapping/NpgsqlMultirangeTypeMapping.cs
...G/Storage/Internal/Mapping/NpgsqlMultirangeTypeMapping.cs
+5
-2
test/EFCore.PG.NodaTime.FunctionalTests/NpgsqlNodaTimeTypeMappingTest.cs
...NodaTime.FunctionalTests/NpgsqlNodaTimeTypeMappingTest.cs
+330
-113
未找到文件。
src/EFCore.PG.NodaTime/EFCore.PG.NodaTime.csproj
浏览文件 @
5316df8f
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
<ItemGroup>
<ItemGroup>
<Compile Include="..\Shared\*.cs" />
<Compile Include="..\Shared\*.cs" />
<None Include="README.md" Pack="true" PackagePath="\"/>
<None Include="README.md" Pack="true" PackagePath="\"
/>
<None Include="build\**\*">
<None Include="build\**\*">
<Pack>True</Pack>
<Pack>True</Pack>
<PackagePath>build</PackagePath>
<PackagePath>build</PackagePath>
...
...
src/EFCore.PG.NodaTime/Storage/Internal/DateIntervalMultirangeMapping.cs
0 → 100644
浏览文件 @
5316df8f
using
Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.Mapping
;
// ReSharper disable once CheckNamespace
namespace
Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal
;
public
class
DateIntervalMultirangeMapping
:
NpgsqlTypeMapping
{
private
readonly
DateIntervalRangeMapping
_dateIntervalRangeMapping
;
public
DateIntervalMultirangeMapping
(
Type
clrType
,
DateIntervalRangeMapping
dateIntervalRangeMapping
)
:
base
(
"datemultirange"
,
clrType
,
NpgsqlDbType
.
DateMultirange
)
=>
_dateIntervalRangeMapping
=
dateIntervalRangeMapping
;
protected
DateIntervalMultirangeMapping
(
RelationalTypeMappingParameters
parameters
,
DateIntervalRangeMapping
dateIntervalRangeMapping
)
:
base
(
parameters
,
NpgsqlDbType
.
DateMultirange
)
=>
_dateIntervalRangeMapping
=
dateIntervalRangeMapping
;
protected
override
RelationalTypeMapping
Clone
(
RelationalTypeMappingParameters
parameters
)
=>
new
DateIntervalMultirangeMapping
(
parameters
,
_dateIntervalRangeMapping
);
public
override
RelationalTypeMapping
Clone
(
string
storeType
,
int
?
size
)
=>
new
DateIntervalMultirangeMapping
(
Parameters
.
WithStoreTypeAndSize
(
storeType
,
size
),
_dateIntervalRangeMapping
);
public
override
CoreTypeMapping
Clone
(
ValueConverter
?
converter
)
=>
new
DateIntervalMultirangeMapping
(
Parameters
.
WithComposedConverter
(
converter
),
_dateIntervalRangeMapping
);
protected
override
string
GenerateNonNullSqlLiteral
(
object
value
)
=>
NpgsqlMultirangeTypeMapping
.
GenerateNonNullSqlLiteral
(
value
,
_dateIntervalRangeMapping
,
"datemultirange"
);
}
\ No newline at end of file
src/EFCore.PG.NodaTime/Storage/Internal/DateIntervalMapping.cs
→
src/EFCore.PG.NodaTime/Storage/Internal/DateInterval
Range
Mapping.cs
浏览文件 @
5316df8f
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
// ReSharper disable once CheckNamespace
// ReSharper disable once CheckNamespace
namespace
Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal
;
namespace
Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal
;
public
class
DateIntervalMapping
:
NpgsqlTypeMapping
public
class
DateInterval
Range
Mapping
:
NpgsqlTypeMapping
{
{
private
static
readonly
ConstructorInfo
_constructorWithDates
=
private
static
readonly
ConstructorInfo
_constructorWithDates
=
typeof
(
DateInterval
).
GetConstructor
(
new
[]
{
typeof
(
LocalDate
),
typeof
(
LocalDate
)
})!;
typeof
(
DateInterval
).
GetConstructor
(
new
[]
{
typeof
(
LocalDate
),
typeof
(
LocalDate
)
})!;
...
@@ -12,29 +12,32 @@ public class DateIntervalMapping : NpgsqlTypeMapping
...
@@ -12,29 +12,32 @@ public class DateIntervalMapping : NpgsqlTypeMapping
private
static
readonly
ConstructorInfo
_localDateConstructor
=
private
static
readonly
ConstructorInfo
_localDateConstructor
=
typeof
(
LocalDate
).
GetConstructor
(
new
[]
{
typeof
(
int
),
typeof
(
int
),
typeof
(
int
)
})!;
typeof
(
LocalDate
).
GetConstructor
(
new
[]
{
typeof
(
int
),
typeof
(
int
),
typeof
(
int
)
})!;
public
DateIntervalMapping
()
public
DateInterval
Range
Mapping
()
:
base
(
"daterange"
,
typeof
(
DateInterval
),
NpgsqlDbType
.
DateRange
)
:
base
(
"daterange"
,
typeof
(
DateInterval
),
NpgsqlDbType
.
DateRange
)
{
{
}
}
protected
DateIntervalMapping
(
RelationalTypeMappingParameters
parameters
)
protected
DateInterval
Range
Mapping
(
RelationalTypeMappingParameters
parameters
)
:
base
(
parameters
,
NpgsqlDbType
.
DateRange
)
:
base
(
parameters
,
NpgsqlDbType
.
DateRange
)
{
{
}
}
protected
override
RelationalTypeMapping
Clone
(
RelationalTypeMappingParameters
parameters
)
protected
override
RelationalTypeMapping
Clone
(
RelationalTypeMappingParameters
parameters
)
=>
new
DateIntervalMapping
(
parameters
);
=>
new
DateInterval
Range
Mapping
(
parameters
);
public
override
RelationalTypeMapping
Clone
(
string
storeType
,
int
?
size
)
public
override
RelationalTypeMapping
Clone
(
string
storeType
,
int
?
size
)
=>
new
DateIntervalMapping
(
Parameters
.
WithStoreTypeAndSize
(
storeType
,
size
));
=>
new
DateInterval
Range
Mapping
(
Parameters
.
WithStoreTypeAndSize
(
storeType
,
size
));
public
override
CoreTypeMapping
Clone
(
ValueConverter
?
converter
)
public
override
CoreTypeMapping
Clone
(
ValueConverter
?
converter
)
=>
new
DateIntervalMapping
(
Parameters
.
WithComposedConverter
(
converter
));
=>
new
DateInterval
Range
Mapping
(
Parameters
.
WithComposedConverter
(
converter
));
protected
override
string
GenerateNonNullSqlLiteral
(
object
value
)
protected
override
string
GenerateNonNullSqlLiteral
(
object
value
)
=>
$"'
{
GenerateEmbeddedNonNullSqlLiteral
(
value
)}
'::daterange"
;
protected
override
string
GenerateEmbeddedNonNullSqlLiteral
(
object
value
)
{
{
var
dateIn
v
erval
=
(
DateInterval
)
value
;
var
dateIn
t
erval
=
(
DateInterval
)
value
;
return
$"
'[
{
LocalDatePattern
.
Iso
.
Format
(
dateInverval
.
Start
)}
,
{
LocalDatePattern
.
Iso
.
Format
(
dateInverval
.
End
)}
]'::daterange
"
;
return
$"
[
{
LocalDatePattern
.
Iso
.
Format
(
dateInterval
.
Start
)}
,
{
LocalDatePattern
.
Iso
.
Format
(
dateInterval
.
End
)}
]
"
;
}
}
public
override
Expression
GenerateCodeLiteral
(
object
value
)
public
override
Expression
GenerateCodeLiteral
(
object
value
)
...
...
src/EFCore.PG.NodaTime/Storage/Internal/IntervalMultirangeMapping.cs
0 → 100644
浏览文件 @
5316df8f
using
Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.Mapping
;
// ReSharper disable once CheckNamespace
namespace
Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal
;
public
class
IntervalMultirangeMapping
:
NpgsqlTypeMapping
{
private
readonly
IntervalRangeMapping
_intervalRangeMapping
;
public
IntervalMultirangeMapping
(
Type
clrType
,
IntervalRangeMapping
intervalRangeMapping
)
:
base
(
"tstzmultirange"
,
clrType
,
NpgsqlDbType
.
TimestampTzMultirange
)
=>
_intervalRangeMapping
=
intervalRangeMapping
;
protected
IntervalMultirangeMapping
(
RelationalTypeMappingParameters
parameters
,
IntervalRangeMapping
intervalRangeMapping
)
:
base
(
parameters
,
NpgsqlDbType
.
DateMultirange
)
=>
_intervalRangeMapping
=
intervalRangeMapping
;
protected
override
RelationalTypeMapping
Clone
(
RelationalTypeMappingParameters
parameters
)
=>
new
IntervalMultirangeMapping
(
parameters
,
_intervalRangeMapping
);
public
override
RelationalTypeMapping
Clone
(
string
storeType
,
int
?
size
)
=>
new
IntervalMultirangeMapping
(
Parameters
.
WithStoreTypeAndSize
(
storeType
,
size
),
_intervalRangeMapping
);
public
override
CoreTypeMapping
Clone
(
ValueConverter
?
converter
)
=>
new
IntervalMultirangeMapping
(
Parameters
.
WithComposedConverter
(
converter
),
_intervalRangeMapping
);
protected
override
string
GenerateNonNullSqlLiteral
(
object
value
)
=>
NpgsqlMultirangeTypeMapping
.
GenerateNonNullSqlLiteral
(
value
,
_intervalRangeMapping
,
"tstzmultirange"
);
}
\ No newline at end of file
src/EFCore.PG.NodaTime/Storage/Internal/IntervalMapping.cs
→
src/EFCore.PG.NodaTime/Storage/Internal/Interval
Range
Mapping.cs
浏览文件 @
5316df8f
// ReSharper disable once CheckNamespace
// ReSharper disable once CheckNamespace
using
System.Text
;
using
NodaTime.Text
;
using
NodaTime.Text
;
using
Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.Mapping
;
using
Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.Mapping
;
// ReSharper disable once CheckNamespace
// ReSharper disable once CheckNamespace
namespace
Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal
;
namespace
Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal
;
public
class
IntervalMapping
:
NpgsqlTypeMapping
public
class
Interval
Range
Mapping
:
NpgsqlTypeMapping
{
{
private
static
readonly
ConstructorInfo
_constructor
=
private
static
readonly
ConstructorInfo
_constructor
=
typeof
(
Interval
).
GetConstructor
(
new
[]
{
typeof
(
Instant
),
typeof
(
Instant
)
})!;
typeof
(
Interval
).
GetConstructor
(
new
[]
{
typeof
(
Instant
),
typeof
(
Instant
)
})!;
...
@@ -14,37 +15,49 @@ public class IntervalMapping : NpgsqlTypeMapping
...
@@ -14,37 +15,49 @@ public class IntervalMapping : NpgsqlTypeMapping
private
static
readonly
ConstructorInfo
_constructorWithNulls
=
private
static
readonly
ConstructorInfo
_constructorWithNulls
=
typeof
(
Interval
).
GetConstructor
(
new
[]
{
typeof
(
Instant
?),
typeof
(
Instant
?)
})!;
typeof
(
Interval
).
GetConstructor
(
new
[]
{
typeof
(
Instant
?),
typeof
(
Instant
?)
})!;
public
IntervalMapping
()
public
Interval
Range
Mapping
()
:
base
(
"tstzrange"
,
typeof
(
Interval
),
NpgsqlDbType
.
TimestampTzRange
)
:
base
(
"tstzrange"
,
typeof
(
Interval
),
NpgsqlDbType
.
TimestampTzRange
)
{
{
}
}
protected
IntervalMapping
(
RelationalTypeMappingParameters
parameters
)
protected
Interval
Range
Mapping
(
RelationalTypeMappingParameters
parameters
)
:
base
(
parameters
,
NpgsqlDbType
.
TimestampTzRange
)
:
base
(
parameters
,
NpgsqlDbType
.
TimestampTzRange
)
{
{
}
}
protected
override
RelationalTypeMapping
Clone
(
RelationalTypeMappingParameters
parameters
)
protected
override
RelationalTypeMapping
Clone
(
RelationalTypeMappingParameters
parameters
)
=>
new
IntervalMapping
(
parameters
);
=>
new
Interval
Range
Mapping
(
parameters
);
public
override
RelationalTypeMapping
Clone
(
string
storeType
,
int
?
size
)
public
override
RelationalTypeMapping
Clone
(
string
storeType
,
int
?
size
)
=>
new
IntervalMapping
(
Parameters
.
WithStoreTypeAndSize
(
storeType
,
size
));
=>
new
Interval
Range
Mapping
(
Parameters
.
WithStoreTypeAndSize
(
storeType
,
size
));
public
override
CoreTypeMapping
Clone
(
ValueConverter
?
converter
)
public
override
CoreTypeMapping
Clone
(
ValueConverter
?
converter
)
=>
new
IntervalMapping
(
Parameters
.
WithComposedConverter
(
converter
));
=>
new
Interval
Range
Mapping
(
Parameters
.
WithComposedConverter
(
converter
));
protected
override
string
GenerateNonNullSqlLiteral
(
object
value
)
protected
override
string
GenerateNonNullSqlLiteral
(
object
value
)
=>
$"'
{
GenerateEmbeddedNonNullSqlLiteral
(
value
)}
'::tstzrange"
;
protected
override
string
GenerateEmbeddedNonNullSqlLiteral
(
object
value
)
{
{
var
interval
=
(
Interval
)
value
;
var
interval
=
(
Interval
)
value
;
var
start
=
interval
.
HasStart
var
stringBuilder
=
new
StringBuilder
(
"["
);
?
InstantPattern
.
ExtendedIso
.
Format
(
interval
.
Start
)
:
""
;
if
(
interval
.
HasStart
)
var
end
=
interval
.
HasEnd
{
?
InstantPattern
.
ExtendedIso
.
Format
(
interval
.
End
)
stringBuilder
.
Append
(
InstantPattern
.
ExtendedIso
.
Format
(
interval
.
Start
));
:
""
;
}
stringBuilder
.
Append
(
','
);
if
(
interval
.
HasEnd
)
{
stringBuilder
.
Append
(
InstantPattern
.
ExtendedIso
.
Format
(
interval
.
End
));
}
stringBuilder
.
Append
(
')'
);
return
$"'[
{
start
}
,
{
end
}
)'::tstzrange"
;
return
stringBuilder
.
ToString
()
;
}
}
public
override
Expression
GenerateCodeLiteral
(
object
value
)
public
override
Expression
GenerateCodeLiteral
(
object
value
)
...
...
src/EFCore.PG.NodaTime/Storage/Internal/NpgsqlNodaTimeTypeMappingSourcePlugin.cs
浏览文件 @
5316df8f
...
@@ -38,15 +38,34 @@ static NpgsqlNodaTimeTypeMappingSourcePlugin()
...
@@ -38,15 +38,34 @@ static NpgsqlNodaTimeTypeMappingSourcePlugin()
private
readonly
PeriodIntervalMapping
_periodInterval
=
new
();
private
readonly
PeriodIntervalMapping
_periodInterval
=
new
();
private
readonly
DurationIntervalMapping
_durationInterval
=
new
();
private
readonly
DurationIntervalMapping
_durationInterval
=
new
();
// Built-in ranges
private
readonly
NpgsqlRangeTypeMapping
_timestampLocalDateTimeRange
;
private
readonly
NpgsqlRangeTypeMapping
_timestampLocalDateTimeRange
;
private
readonly
NpgsqlRangeTypeMapping
_legacyTimestampInstantRange
;
private
readonly
NpgsqlRangeTypeMapping
_legacyTimestampInstantRange
;
private
readonly
NpgsqlRangeTypeMapping
_timestamptzInstantRange
;
private
readonly
NpgsqlRangeTypeMapping
_timestamptzInstantRange
;
private
readonly
NpgsqlRangeTypeMapping
_timestamptzZonedDateTimeRange
;
private
readonly
NpgsqlRangeTypeMapping
_timestamptzZonedDateTimeRange
;
private
readonly
NpgsqlRangeTypeMapping
_timestamptzOffsetDateTimeRange
;
private
readonly
NpgsqlRangeTypeMapping
_timestamptzOffsetDateTimeRange
;
private
readonly
NpgsqlRangeTypeMapping
_dateRange
;
private
readonly
NpgsqlRangeTypeMapping
_dateRange
;
private
readonly
DateIntervalRangeMapping
_dateIntervalRange
=
new
();
private
readonly
DateIntervalMapping
_dateInterval
=
new
();
private
readonly
IntervalRangeMapping
_intervalRange
=
new
();
private
readonly
IntervalMapping
_interval
=
new
();
// Built-in multiranges
private
readonly
NpgsqlMultirangeTypeMapping
_timestampLocalDateTimeMultirangeArray
;
private
readonly
NpgsqlMultirangeTypeMapping
_legacyTimestampInstantMultirangeArray
;
private
readonly
NpgsqlMultirangeTypeMapping
_timestamptzInstantMultirangeArray
;
private
readonly
NpgsqlMultirangeTypeMapping
_timestamptzZonedDateTimeMultirangeArray
;
private
readonly
NpgsqlMultirangeTypeMapping
_timestamptzOffsetDateTimeMultirangeArray
;
private
readonly
NpgsqlMultirangeTypeMapping
_dateRangeMultirangeArray
;
private
readonly
DateIntervalMultirangeMapping
_dateIntervalMultirangeArray
;
private
readonly
IntervalMultirangeMapping
_intervalMultirangeArray
;
private
readonly
NpgsqlMultirangeTypeMapping
_timestampLocalDateTimeMultirangeList
;
private
readonly
NpgsqlMultirangeTypeMapping
_legacyTimestampInstantMultirangeList
;
private
readonly
NpgsqlMultirangeTypeMapping
_timestamptzInstantMultirangeList
;
private
readonly
NpgsqlMultirangeTypeMapping
_timestamptzZonedDateTimeMultirangeList
;
private
readonly
NpgsqlMultirangeTypeMapping
_timestamptzOffsetDateTimeMultirangeList
;
private
readonly
NpgsqlMultirangeTypeMapping
_dateRangeMultirangeList
;
private
readonly
DateIntervalMultirangeMapping
_dateIntervalMultirangeList
;
private
readonly
IntervalMultirangeMapping
_intervalMultirangeList
;
#
endregion
#
endregion
...
@@ -55,10 +74,10 @@ static NpgsqlNodaTimeTypeMappingSourcePlugin()
...
@@ -55,10 +74,10 @@ static NpgsqlNodaTimeTypeMappingSourcePlugin()
/// </summary>
/// </summary>
public
NpgsqlNodaTimeTypeMappingSourcePlugin
(
ISqlGenerationHelper
sqlGenerationHelper
)
public
NpgsqlNodaTimeTypeMappingSourcePlugin
(
ISqlGenerationHelper
sqlGenerationHelper
)
{
{
_legacyTimestampInstantRange
=
new
NpgsqlRangeTypeMapping
(
"tsrange"
,
typeof
(
NpgsqlRange
<
Instant
>),
_legacyTimestampInstant
,
sqlGenerationHelper
);
_timestampLocalDateTimeRange
_timestampLocalDateTimeRange
=
new
NpgsqlRangeTypeMapping
(
"tsrange"
,
typeof
(
NpgsqlRange
<
LocalDateTime
>),
_timestampLocalDateTime
,
sqlGenerationHelper
);
=
new
NpgsqlRangeTypeMapping
(
"tsrange"
,
typeof
(
NpgsqlRange
<
LocalDateTime
>),
_timestampLocalDateTime
,
sqlGenerationHelper
);
_legacyTimestampInstantRange
=
new
NpgsqlRangeTypeMapping
(
"tsrange"
,
typeof
(
NpgsqlRange
<
Instant
>),
_legacyTimestampInstant
,
sqlGenerationHelper
);
_timestamptzInstantRange
_timestamptzInstantRange
=
new
NpgsqlRangeTypeMapping
(
"tstzrange"
,
typeof
(
NpgsqlRange
<
Instant
>),
_timestamptzInstant
,
sqlGenerationHelper
);
=
new
NpgsqlRangeTypeMapping
(
"tstzrange"
,
typeof
(
NpgsqlRange
<
Instant
>),
_timestamptzInstant
,
sqlGenerationHelper
);
_timestamptzZonedDateTimeRange
_timestamptzZonedDateTimeRange
...
@@ -68,6 +87,36 @@ public NpgsqlNodaTimeTypeMappingSourcePlugin(ISqlGenerationHelper sqlGenerationH
...
@@ -68,6 +87,36 @@ public NpgsqlNodaTimeTypeMappingSourcePlugin(ISqlGenerationHelper sqlGenerationH
_dateRange
_dateRange
=
new
NpgsqlRangeTypeMapping
(
"daterange"
,
typeof
(
NpgsqlRange
<
LocalDate
>),
_date
,
sqlGenerationHelper
);
=
new
NpgsqlRangeTypeMapping
(
"daterange"
,
typeof
(
NpgsqlRange
<
LocalDate
>),
_date
,
sqlGenerationHelper
);
_timestampLocalDateTimeMultirangeArray
=
new
NpgsqlMultirangeTypeMapping
(
"tsmultirange"
,
typeof
(
NpgsqlRange
<
LocalDateTime
>[]),
_timestampLocalDateTimeRange
,
sqlGenerationHelper
);
_legacyTimestampInstantMultirangeArray
=
new
NpgsqlMultirangeTypeMapping
(
"tsmultirange"
,
typeof
(
NpgsqlRange
<
Instant
>[]),
_legacyTimestampInstantRange
,
sqlGenerationHelper
);
_timestamptzInstantMultirangeArray
=
new
NpgsqlMultirangeTypeMapping
(
"tstzmultirange"
,
typeof
(
NpgsqlRange
<
Instant
>[]),
_timestamptzInstantRange
,
sqlGenerationHelper
);
_timestamptzZonedDateTimeMultirangeArray
=
new
NpgsqlMultirangeTypeMapping
(
"tstzmultirange"
,
typeof
(
NpgsqlRange
<
ZonedDateTime
>[]),
_timestamptzZonedDateTimeRange
,
sqlGenerationHelper
);
_timestamptzOffsetDateTimeMultirangeArray
=
new
NpgsqlMultirangeTypeMapping
(
"tstzmultirange"
,
typeof
(
NpgsqlRange
<
OffsetDateTime
>[]),
_timestamptzOffsetDateTimeRange
,
sqlGenerationHelper
);
_dateRangeMultirangeArray
=
new
NpgsqlMultirangeTypeMapping
(
"datemultirange"
,
typeof
(
NpgsqlRange
<
LocalDate
>[]),
_dateRange
,
sqlGenerationHelper
);
_dateIntervalMultirangeArray
=
new
DateIntervalMultirangeMapping
(
typeof
(
DateInterval
[]),
_dateIntervalRange
);
_intervalMultirangeArray
=
new
IntervalMultirangeMapping
(
typeof
(
Interval
[]),
_intervalRange
);
_timestampLocalDateTimeMultirangeList
=
new
NpgsqlMultirangeTypeMapping
(
"tsmultirange"
,
typeof
(
List
<
NpgsqlRange
<
LocalDateTime
>>),
_timestampLocalDateTimeRange
,
sqlGenerationHelper
);
_legacyTimestampInstantMultirangeList
=
new
NpgsqlMultirangeTypeMapping
(
"tsmultirange"
,
typeof
(
List
<
NpgsqlRange
<
Instant
>>),
_legacyTimestampInstantRange
,
sqlGenerationHelper
);
_timestamptzInstantMultirangeList
=
new
NpgsqlMultirangeTypeMapping
(
"tstzmultirange"
,
typeof
(
List
<
NpgsqlRange
<
Instant
>>),
_timestamptzInstantRange
,
sqlGenerationHelper
);
_timestamptzZonedDateTimeMultirangeList
=
new
NpgsqlMultirangeTypeMapping
(
"tstzmultirange"
,
typeof
(
List
<
NpgsqlRange
<
ZonedDateTime
>>),
_timestamptzZonedDateTimeRange
,
sqlGenerationHelper
);
_timestamptzOffsetDateTimeMultirangeList
=
new
NpgsqlMultirangeTypeMapping
(
"tstzmultirange"
,
typeof
(
List
<
NpgsqlRange
<
OffsetDateTime
>>),
_timestamptzOffsetDateTimeRange
,
sqlGenerationHelper
);
_dateRangeMultirangeList
=
new
NpgsqlMultirangeTypeMapping
(
"datemultirange"
,
typeof
(
List
<
NpgsqlRange
<
LocalDate
>>),
_dateRange
,
sqlGenerationHelper
);
_dateIntervalMultirangeList
=
new
DateIntervalMultirangeMapping
(
typeof
(
List
<
DateInterval
>),
_dateIntervalRange
);
_intervalMultirangeList
=
new
IntervalMultirangeMapping
(
typeof
(
List
<
Interval
>),
_intervalRange
);
var
storeTypeMappings
=
new
Dictionary
<
string
,
RelationalTypeMapping
[
]>
(
StringComparer
.
OrdinalIgnoreCase
)
var
storeTypeMappings
=
new
Dictionary
<
string
,
RelationalTypeMapping
[
]>
(
StringComparer
.
OrdinalIgnoreCase
)
{
{
{
{
...
@@ -88,8 +137,29 @@ public NpgsqlNodaTimeTypeMappingSourcePlugin(ISqlGenerationHelper sqlGenerationH
...
@@ -88,8 +137,29 @@ public NpgsqlNodaTimeTypeMappingSourcePlugin(ISqlGenerationHelper sqlGenerationH
?
new
RelationalTypeMapping
[]
{
_legacyTimestampInstantRange
,
_timestampLocalDateTimeRange
}
?
new
RelationalTypeMapping
[]
{
_legacyTimestampInstantRange
,
_timestampLocalDateTimeRange
}
:
new
RelationalTypeMapping
[]
{
_timestampLocalDateTimeRange
,
_legacyTimestampInstantRange
}
:
new
RelationalTypeMapping
[]
{
_timestampLocalDateTimeRange
,
_legacyTimestampInstantRange
}
},
},
{
"tstzrange"
,
new
RelationalTypeMapping
[]
{
_interval
,
_timestamptzInstantRange
,
_timestamptzZonedDateTimeRange
,
_timestamptzOffsetDateTimeRange
}
},
{
"tstzrange"
,
new
RelationalTypeMapping
[]
{
_intervalRange
,
_timestamptzInstantRange
,
_timestamptzZonedDateTimeRange
,
_timestamptzOffsetDateTimeRange
}
},
{
"daterange"
,
new
RelationalTypeMapping
[]
{
_dateInterval
,
_dateRange
}
}
{
"daterange"
,
new
RelationalTypeMapping
[]
{
_dateIntervalRange
,
_dateRange
}
},
{
"tsmultirange"
,
LegacyTimestampBehavior
?
new
RelationalTypeMapping
[]
{
_legacyTimestampInstantMultirangeArray
,
_legacyTimestampInstantMultirangeList
,
_timestampLocalDateTimeMultirangeArray
,
_timestampLocalDateTimeMultirangeList
}
:
new
RelationalTypeMapping
[]
{
_timestampLocalDateTimeMultirangeArray
,
_timestampLocalDateTimeMultirangeList
,
_legacyTimestampInstantMultirangeArray
,
_legacyTimestampInstantMultirangeList
}
},
{
"tstzmultirange"
,
new
RelationalTypeMapping
[]
{
_intervalMultirangeArray
,
_intervalMultirangeList
,
_timestamptzInstantMultirangeArray
,
_timestamptzInstantMultirangeList
,
_timestamptzZonedDateTimeMultirangeArray
,
_timestamptzZonedDateTimeMultirangeList
,
_timestamptzOffsetDateTimeMultirangeArray
,
_timestamptzOffsetDateTimeMultirangeList
}
},
{
"datemultirange"
,
new
RelationalTypeMapping
[]
{
_dateIntervalMultirangeArray
,
_dateIntervalMultirangeList
,
_dateRangeMultirangeArray
,
_dateRangeMultirangeList
}
}
};
};
// Set up aliases
// Set up aliases
...
@@ -116,8 +186,24 @@ public NpgsqlNodaTimeTypeMappingSourcePlugin(ISqlGenerationHelper sqlGenerationH
...
@@ -116,8 +186,24 @@ public NpgsqlNodaTimeTypeMappingSourcePlugin(ISqlGenerationHelper sqlGenerationH
{
typeof
(
NpgsqlRange
<
ZonedDateTime
>),
_timestamptzZonedDateTimeRange
},
{
typeof
(
NpgsqlRange
<
ZonedDateTime
>),
_timestamptzZonedDateTimeRange
},
{
typeof
(
NpgsqlRange
<
OffsetDateTime
>),
_timestamptzOffsetDateTimeRange
},
{
typeof
(
NpgsqlRange
<
OffsetDateTime
>),
_timestamptzOffsetDateTimeRange
},
{
typeof
(
NpgsqlRange
<
LocalDate
>),
_dateRange
},
{
typeof
(
NpgsqlRange
<
LocalDate
>),
_dateRange
},
{
typeof
(
DateInterval
),
_dateInterval
},
{
typeof
(
DateInterval
),
_dateIntervalRange
},
{
typeof
(
Interval
),
_interval
}
{
typeof
(
Interval
),
_intervalRange
},
{
typeof
(
NpgsqlRange
<
Instant
>[]),
LegacyTimestampBehavior
?
_legacyTimestampInstantMultirangeArray
:
_timestamptzInstantMultirangeArray
},
{
typeof
(
NpgsqlRange
<
LocalDateTime
>[]),
_timestampLocalDateTimeMultirangeArray
},
{
typeof
(
NpgsqlRange
<
ZonedDateTime
>[]),
_timestamptzZonedDateTimeMultirangeArray
},
{
typeof
(
NpgsqlRange
<
OffsetDateTime
>[]),
_timestamptzOffsetDateTimeMultirangeArray
},
{
typeof
(
NpgsqlRange
<
LocalDate
>[]),
_dateRangeMultirangeArray
},
{
typeof
(
DateInterval
[]),
_dateIntervalMultirangeArray
},
{
typeof
(
Interval
[]),
_intervalMultirangeArray
},
{
typeof
(
List
<
NpgsqlRange
<
Instant
>>),
LegacyTimestampBehavior
?
_legacyTimestampInstantMultirangeList
:
_timestamptzInstantMultirangeList
},
{
typeof
(
List
<
NpgsqlRange
<
LocalDateTime
>>),
_timestampLocalDateTimeMultirangeList
},
{
typeof
(
List
<
NpgsqlRange
<
ZonedDateTime
>>),
_timestamptzZonedDateTimeMultirangeList
},
{
typeof
(
List
<
NpgsqlRange
<
OffsetDateTime
>>),
_timestamptzOffsetDateTimeMultirangeList
},
{
typeof
(
List
<
NpgsqlRange
<
LocalDate
>>),
_dateRangeMultirangeList
},
{
typeof
(
List
<
DateInterval
>),
_dateIntervalMultirangeList
},
{
typeof
(
List
<
Interval
>),
_intervalMultirangeList
}
};
};
StoreTypeMappings
=
new
ConcurrentDictionary
<
string
,
RelationalTypeMapping
[
]>
(
storeTypeMappings
,
StringComparer
.
OrdinalIgnoreCase
);
StoreTypeMappings
=
new
ConcurrentDictionary
<
string
,
RelationalTypeMapping
[
]>
(
storeTypeMappings
,
StringComparer
.
OrdinalIgnoreCase
);
...
...
src/EFCore.PG/Storage/Internal/Mapping/NpgsqlMultirangeTypeMapping.cs
浏览文件 @
5316df8f
...
@@ -76,6 +76,9 @@ protected override RelationalTypeMapping Clone(RelationalTypeMappingParameters p
...
@@ -76,6 +76,9 @@ protected override RelationalTypeMapping Clone(RelationalTypeMappingParameters p
=>
new
NpgsqlMultirangeTypeMapping
(
parameters
,
NpgsqlDbType
,
RangeMapping
,
_sqlGenerationHelper
);
=>
new
NpgsqlMultirangeTypeMapping
(
parameters
,
NpgsqlDbType
,
RangeMapping
,
_sqlGenerationHelper
);
protected
override
string
GenerateNonNullSqlLiteral
(
object
value
)
protected
override
string
GenerateNonNullSqlLiteral
(
object
value
)
=>
GenerateNonNullSqlLiteral
(
value
,
RangeMapping
,
StoreType
);
public
static
string
GenerateNonNullSqlLiteral
(
object
value
,
RelationalTypeMapping
rangeMapping
,
string
multirangeStoreType
)
{
{
var
multirange
=
(
IList
)
value
;
var
multirange
=
(
IList
)
value
;
...
@@ -84,7 +87,7 @@ protected override string GenerateNonNullSqlLiteral(object value)
...
@@ -84,7 +87,7 @@ protected override string GenerateNonNullSqlLiteral(object value)
for
(
var
i
=
0
;
i
<
multirange
.
Count
;
i
++)
for
(
var
i
=
0
;
i
<
multirange
.
Count
;
i
++)
{
{
sb
.
Append
(
R
angeMapping
.
GenerateEmbeddedSqlLiteral
(
multirange
[
i
]));
sb
.
Append
(
r
angeMapping
.
GenerateEmbeddedSqlLiteral
(
multirange
[
i
]));
if
(
i
<
multirange
.
Count
-
1
)
if
(
i
<
multirange
.
Count
-
1
)
{
{
sb
.
Append
(
", "
);
sb
.
Append
(
", "
);
...
@@ -92,7 +95,7 @@ protected override string GenerateNonNullSqlLiteral(object value)
...
@@ -92,7 +95,7 @@ protected override string GenerateNonNullSqlLiteral(object value)
}
}
sb
.
Append
(
"}'::"
);
sb
.
Append
(
"}'::"
);
sb
.
Append
(
StoreType
);
sb
.
Append
(
multirange
StoreType
);
return
sb
.
ToString
();
return
sb
.
ToString
();
}
}
...
...
test/EFCore.PG.NodaTime.FunctionalTests/NpgsqlNodaTimeTypeMappingTest.cs
浏览文件 @
5316df8f
此差异已折叠。
点击以展开。
jobily
@jobily
mentioned in commit
376c503e
·
9月 18, 2023
mentioned in commit
376c503e
mentioned in commit 376c503e4b1fe5d2fe7c7f8b5a09765e2d3834a1
开关提交列表
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录