Skip to content

Commit 2b050a1

Browse files
committed
VTimePointsToRanges.Oracle.sql and VNaviForeignKey.Oracle.sql
1 parent 2b475d4 commit 2b050a1

File tree

8 files changed

+117
-7
lines changed

8 files changed

+117
-7
lines changed

T4SQLTemplateLibrary/Databases/SqlServer/Schema Objects/Schemas/T4SQL/Programmability/Stored Procedures/T4SQL.ENGINE_GET_FOREIGN_KEY.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ AS
1414
SELECT
1515
@outTable_Schema = S.name,
1616
@outTable_Name = T.name,
17-
@outTable_Name = QUOTENAME(S.name) + N'.' + QUOTENAME(T.name)
17+
@outQualified_Name = QUOTENAME(S.name) + N'.' + QUOTENAME(T.name)
1818
FROM
1919
sys.schemas S,
2020
sys.objects T

T4SQLTemplateLibrary/SqlBuilder/DataAccess/DbPackage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ private static void LoadForeignKeys(this DbAccess dbAccess, DbmsRelationTree for
147147
foreignKeyBaseTable.TableName = outTable_Name.Parameter<string>();
148148
foreignKeyBaseTable.QualifiedName = outQualified_Name.Parameter<string>();
149149

150-
foreignKeyBaseTable.Columns = ListTableColumns(dbAccess, foreignKeyBaseTable.TableName).ToArray();
150+
foreignKeyBaseTable.Columns = ListTableColumns(dbAccess, foreignKeyBaseTable.QualifiedName).ToArray();
151151

152152
foreach (DbmsForeignKey fk in foreignKeyBaseTable.ForeignKeys)
153153
LoadForeignKeys(dbAccess, fk.PrimaryUniqueKeyBaseTable);

T4SQLTemplateLibrary/T4SQL.Base/MetaData/JoinedTable.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ private string BuildJoinClause(DbmsRelationTree startTable)
110110
{
111111
StringBuilder joinClause = new StringBuilder();
112112

113-
joinClause.AppendFormat(startTable.TableName);
113+
joinClause.AppendFormat(startTable.QualifiedName);
114114
joinClause.Append(" ");
115115
joinClause.AppendLine(startTable.LinkProperty.Alias);
116116

T4SQLTemplateLibrary/T4Templates/Assoc/VNaviForeignKey.Oracle.sql

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,24 @@ SELECT
55
FROM
66
<#= JoinClause #>
77
WITH READ ONLY;
8+
9+
----------------------------------------------------------------------------------------------------
10+
--
11+
-- Copyright 2013 Abel Cheng
12+
-- This source code is subject to terms and conditions of the Apache License, Version 2.0.
13+
-- See http://www.apache.org/licenses/LICENSE-2.0.
14+
-- All other rights reserved.
15+
-- You must not remove this notice, or any other, from this software.
16+
--
17+
-- Original Author: Abel Cheng <[email protected]>
18+
-- Created Date: ‎‎‎‎July ‎03, ‎2013, ‏‎12:56:08 AM
19+
-- Primary Host: http://t4sql.codeplex.com
20+
-- Change Log:
21+
-- Author Date Comment
22+
--
23+
--
24+
--
25+
--
26+
-- (Keep code clean)
27+
--
28+
----------------------------------------------------------------------------------------------------

T4SQLTemplateLibrary/T4Templates/Assoc/VNaviForeignKey.cs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,30 @@ public virtual string TransformText()
148148

149149
#line default
150150
#line hidden
151-
this.Write("\r\nWITH READ ONLY;\r\n");
151+
this.Write(@"
152+
WITH READ ONLY;
153+
154+
----------------------------------------------------------------------------------------------------
155+
--
156+
-- Copyright 2013 Abel Cheng
157+
-- This source code is subject to terms and conditions of the Apache License, Version 2.0.
158+
-- See http://www.apache.org/licenses/LICENSE-2.0.
159+
-- All other rights reserved.
160+
-- You must not remove this notice, or any other, from this software.
161+
--
162+
-- Original Author: Abel Cheng <[email protected]>
163+
-- Created Date: ‎‎‎‎July ‎03, ‎2013, ‏‎12:56:08 AM
164+
-- Primary Host: http://t4sql.codeplex.com
165+
-- Change Log:
166+
-- Author Date Comment
167+
--
168+
--
169+
--
170+
--
171+
-- (Keep code clean)
172+
--
173+
----------------------------------------------------------------------------------------------------
174+
");
152175
this.Write("\r\n");
153176

154177
#line 15 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Assoc\VNaviForeignKey.tt"

T4SQLTemplateLibrary/T4Templates/Date/VTimePointsToRanges.Oracle.sql

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,24 @@ FROM
1212
<#= SourceView #>
1313

1414
WITH READ ONLY;
15+
16+
----------------------------------------------------------------------------------------------------
17+
--
18+
-- Copyright 2013 Abel Cheng
19+
-- This source code is subject to terms and conditions of the Apache License, Version 2.0.
20+
-- See http://www.apache.org/licenses/LICENSE-2.0.
21+
-- All other rights reserved.
22+
-- You must not remove this notice, or any other, from this software.
23+
--
24+
-- Original Author: Abel Cheng <[email protected]>
25+
-- Created Date: ‎May ‎20, ‎2013, ‏‎12:00:44 AM
26+
-- Primary Host: http://t4sql.codeplex.com
27+
-- Change Log:
28+
-- Author Date Comment
29+
--
30+
--
31+
--
32+
--
33+
-- (Keep code clean)
34+
--
35+
----------------------------------------------------------------------------------------------------

T4SQLTemplateLibrary/T4Templates/Date/VTimePointsToRanges.cs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,31 @@ public virtual string TransformText()
352352

353353
#line default
354354
#line hidden
355-
this.Write("\r\n\r\nWITH READ ONLY;\r\n");
355+
this.Write(@"
356+
357+
WITH READ ONLY;
358+
359+
----------------------------------------------------------------------------------------------------
360+
--
361+
-- Copyright 2013 Abel Cheng
362+
-- This source code is subject to terms and conditions of the Apache License, Version 2.0.
363+
-- See http://www.apache.org/licenses/LICENSE-2.0.
364+
-- All other rights reserved.
365+
-- You must not remove this notice, or any other, from this software.
366+
--
367+
-- Original Author: Abel Cheng <[email protected]>
368+
-- Created Date: ‎May ‎20, ‎2013, ‏‎12:00:44 AM
369+
-- Primary Host: http://t4sql.codeplex.com
370+
-- Change Log:
371+
-- Author Date Comment
372+
--
373+
--
374+
--
375+
--
376+
-- (Keep code clean)
377+
--
378+
----------------------------------------------------------------------------------------------------
379+
");
356380
this.Write("\r\n");
357381

358382
#line 15 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Date\VTimePointsToRanges.tt"

T4SQLTemplateLibrary/T4Templates/Date/VTimePointsToRanges.partial.cs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.ComponentModel;
4+
using System.Text.RegularExpressions;
45

56
namespace T4SQL.Date
67
{
@@ -24,7 +25,7 @@ public TemplateSpec GetPropertiesSpec()
2425
spec.AddProperty("RangeStartDateColumn", "START_DATE", null, "{+}Time range Start Date column");
2526
spec.AddProperty("RangeEndDateColumn", "END_DATE", null, "{+}Time range End Date column");
2627
spec.AddProperty("EndDateNext", "0", null, "[*] 0: [START_DATE <= Time Range <= END_DATE]; 1: [START_DATE <= Time Range < END_DATE)");
27-
spec.AddProperty("DefaultEndDate", "CAST('2999-12-31' AS DATE)", null, "[*]Ultimate END_DATE as the substitute of IS NULL");
28+
spec.AddProperty("DefaultEndDate", "2999-12-31", null, "[*]Ultimate END_DATE as the substitute of IS NULL");
2829

2930
return spec;
3031
}
@@ -42,10 +43,30 @@ public TemplateSpec GetPropertiesSpec()
4243
public string DateColumn { get { return this.GetPropertyValue("DateColumn"); } }
4344
public string RangeStartDateColumn { get { return this.GetPropertyValue("RangeStartDateColumn"); } }
4445
public string RangeEndDateColumn { get { return this.GetPropertyValue("RangeEndDateColumn"); } }
45-
public string DefaultEndDate { get { return this.GetPropertyValue("DefaultEndDate"); } }
4646
public bool IsEndDateNext { get { return this.GetPropertyValue("EndDateNext").IsTrueString(); } }
4747
public IEnumerable<string> KeyColumns { get { return Key_Columns.SplitColumns(); } }
4848

49+
public string DefaultEndDate
50+
{
51+
get
52+
{
53+
string defaultEndDate = this.GetPropertyValue("DefaultEndDate");
54+
55+
if (string.IsNullOrWhiteSpace(defaultEndDate))
56+
return string.Empty;
57+
else
58+
{
59+
Regex rgDate = new Regex(@"\s*'?(?<dt>\d{4}-\d{2}-\d{2})'?\s*");
60+
Match mc = rgDate.Match(defaultEndDate);
61+
62+
if (mc.Success)
63+
return string.Format(((DbmsPlatform == "Oracle") ? "TO_DATE('{0}', 'YYYY-MM-DD')" : "CAST('{0}' AS DATE)"), mc.Groups["dt"].Value);
64+
else
65+
return defaultEndDate;
66+
}
67+
}
68+
}
69+
4970
public IEnumerable<string> SelectColumns
5071
{
5172
get

0 commit comments

Comments
 (0)