Skip to content

Commit

Permalink
#253 rename class name
Browse files Browse the repository at this point in the history
  • Loading branch information
mk3008 committed Nov 4, 2023
1 parent 14955a9 commit 7075408
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace QueryBuilderByLinq.Analysis;

public static class CommonTableParser
public static class CommonTableInfoParser
{
public static List<CommonTableInfo> Parse(Expression exp)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace QueryBuilderByLinq.Analysis;

public static class FromTableParser
public static class FromTableInfoParser
{
public static FromTableInfo? Parse(Expression exp)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace QueryBuilderByLinq.Analysis;

public class JoinTableParser
public class JoinTableInfoParser
{
public static List<JoinTableInfo> Parse(Expression exp)
{
Expand Down
16 changes: 16 additions & 0 deletions src/QueryBuilderByLinq/Analysis/SelectColumnInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Carbunql.Clauses;

namespace QueryBuilderByLinq.Analysis;

public class SelectColumnInfo
{
public SelectColumnInfo(ValueBase value, string alias)
{
Value = value;
Alias = alias;
}

public string Alias { get; private set; }

public ValueBase Value { get; private set; }
}
11 changes: 11 additions & 0 deletions src/QueryBuilderByLinq/Analysis/SelectColumnInfoParser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.Linq.Expressions;

namespace QueryBuilderByLinq.Analysis;

public class SelectColumnInfoParser
{
public static List<JoinTableInfo> Parse(Expression exp)
{
return new List<JoinTableInfo>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace QueryBuilderByLinq.Analysis;

public class WhereParser
public class WhereInfoParser
{
public static ValueBase? Parse(Expression exp)
{
Expand Down
4 changes: 2 additions & 2 deletions src/QueryBuilderByLinq/IQueryableExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ public static SelectQuery ToQueryAsPostgres(this IQueryable source)
{
var exp = (MethodCallExpression)source.Expression;
//ExpressionDebugger.WriteImmediate(exp);
var ctes = CommonTableParser.Parse(exp).ToList();
var from = FromTableParser.Parse(exp);
var ctes = CommonTableInfoParser.Parse(exp).ToList();
var from = FromTableInfoParser.Parse(exp);

var builder = new SelectQueryBuilder(exp);
return builder.Build(exp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

namespace QueryBuilderByLinq.Test.Analysis;

public class CommonTableParserTest
public class CommonTableInfoParserTest
{
private readonly QueryCommandMonitor Monitor;

public CommonTableParserTest(ITestOutputHelper output)
public CommonTableInfoParserTest(ITestOutputHelper output)
{
Monitor = new QueryCommandMonitor(output);
Output = output;
Expand All @@ -27,7 +27,7 @@ from x in FromTable(cte)

Monitor.Log(query);

var ctes = CommonTableParser.Parse(query.Expression);
var ctes = CommonTableInfoParser.Parse(query.Expression);

Assert.Single(ctes);
Assert.Equal("cte", ctes[0].Alias);
Expand All @@ -45,7 +45,7 @@ from x in FromTable(cte1)

Monitor.Log(query);

var ctes = CommonTableParser.Parse(query.Expression);
var ctes = CommonTableInfoParser.Parse(query.Expression);

Assert.Equal(2, ctes.Count);
}
Expand All @@ -65,7 +65,7 @@ from x in FromTable(cte1)

Monitor.Log(query);

var ctes = CommonTableParser.Parse(query.Expression);
var ctes = CommonTableInfoParser.Parse(query.Expression);

Assert.Equal(5, ctes.Count);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

namespace QueryBuilderByLinq.Test.Analysis;

public class FromTableParserTest
public class FromTableInfoParserTest
{
private readonly QueryCommandMonitor Monitor;

public FromTableParserTest(ITestOutputHelper output)
public FromTableInfoParserTest(ITestOutputHelper output)
{
Monitor = new QueryCommandMonitor(output);
Output = output;
Expand All @@ -28,7 +28,7 @@ public void DualTableTest()

Monitor.Log(query);

var from = FromTableParser.Parse(query.Expression);
var from = FromTableInfoParser.Parse(query.Expression);

Assert.Null(from);
}
Expand All @@ -41,7 +41,7 @@ public void TypeTableTest()

Monitor.Log(query);

var from = FromTableParser.Parse(query.Expression);
var from = FromTableInfoParser.Parse(query.Expression);

Assert.Equal("table_a", from?.Table?.Alias);
Assert.Equal("a", from?.Alias);
Expand All @@ -55,7 +55,7 @@ public void StringTableTest()

Monitor.Log(query);

var from = FromTableParser.Parse(query.Expression);
var from = FromTableInfoParser.Parse(query.Expression);

Assert.Equal("TABLE_A", from?.PhysicalName);
Assert.Equal("a", from?.Alias);
Expand All @@ -71,7 +71,7 @@ public void SubQueryTest()

Monitor.Log(query);

var from = FromTableParser.Parse(query.Expression);
var from = FromTableInfoParser.Parse(query.Expression);

Assert.Equal("select a.a_id from table_a as a", from?.Query?.ToOneLineText());
Assert.Equal("x", from?.Alias);
Expand All @@ -88,7 +88,7 @@ from x in FromTable(cte)

Monitor.Log(query);

var from = FromTableParser.Parse(query.Expression);
var from = FromTableInfoParser.Parse(query.Expression);

Assert.Equal("cte", from?.PhysicalName);
Assert.Equal("x", from?.Alias);
Expand All @@ -106,7 +106,7 @@ from x in FromTable(cte1)

Monitor.Log(query);

var from = FromTableParser.Parse(query.Expression);
var from = FromTableInfoParser.Parse(query.Expression);

Assert.Equal("cte1", from?.PhysicalName);
Assert.Equal("x", from?.Alias);
Expand All @@ -127,7 +127,7 @@ from x in FromTable(cte1)

Monitor.Log(query);

var from = FromTableParser.Parse(query.Expression);
var from = FromTableInfoParser.Parse(query.Expression);

Assert.Equal("cte1", from?.PhysicalName);
Assert.Equal("x", from?.Alias);
Expand All @@ -145,7 +145,7 @@ from x in Dual()

Monitor.Log(query);

var from = FromTableParser.Parse(query.Expression);
var from = FromTableInfoParser.Parse(query.Expression);

Assert.Null(from);
}
Expand All @@ -162,7 +162,7 @@ from x in FromTable<table_a>()

Monitor.Log(query);

var from = FromTableParser.Parse(query.Expression);
var from = FromTableInfoParser.Parse(query.Expression);

Assert.Equal("table_a", from?.Table?.Alias);
Assert.Equal("x", from?.Alias);
Expand All @@ -180,7 +180,7 @@ from x in FromTable<table_a>("sales")

Monitor.Log(query);

var from = FromTableParser.Parse(query.Expression);
var from = FromTableInfoParser.Parse(query.Expression);

Assert.Equal("sales", from?.PhysicalName);
Assert.Equal("x", from?.Alias);
Expand All @@ -197,7 +197,7 @@ from x in FromTable(subquery)

Monitor.Log(query);

var from = FromTableParser.Parse(query.Expression);
var from = FromTableInfoParser.Parse(query.Expression);

Assert.Equal("select a.a_id from table_a as a", from?.Query?.ToOneLineText());
Assert.Equal("x", from?.Alias);
Expand Down
2 changes: 1 addition & 1 deletion test/QueryBuilderByLinq.Test/CommonTableTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public CommonTableTest(ITestOutputHelper output)

private void WriteLog(IQueryable query)
{
var from = FromTableParser.Parse(query.Expression);
var from = FromTableInfoParser.Parse(query.Expression);
if (from != null)
{
Output.WriteLine($"from : {from.Alias}");
Expand Down
4 changes: 2 additions & 2 deletions test/QueryBuilderByLinq.Test/QueryCommandMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public QueryCommandMonitor(ITestOutputHelper output)

public void Log(IQueryable query)
{
var from = FromTableParser.Parse(query.Expression);
var from = FromTableInfoParser.Parse(query.Expression);
if (from != null)
{
Output.WriteLine("From");
Expand All @@ -30,7 +30,7 @@ public void Log(IQueryable query)
}
Output.WriteLine("--------------------");

var ctes = CommonTableParser.Parse(query.Expression);
var ctes = CommonTableInfoParser.Parse(query.Expression);
foreach (var cte in ctes)
{
Output.WriteLine($"CTE[{ctes.IndexOf(cte)}] : {cte.Alias}");
Expand Down

0 comments on commit 7075408

Please sign in to comment.