public void CheckCamelCaseSyntax(bool respectColumnSyntax, string expected) { IQueryBuilder qBuilder = new PostgreSqlQueryBuilder() { RespectColumnSyntax = respectColumnSyntax }; var actualSql = qBuilder.From("User").Select("Id", "Name").Sql(); Assert.AreEqual(expected, actualSql); }
public void CheckNoLock(bool useNoLock, string expected) { IQueryBuilder qBuilder = new PostgreSqlQueryBuilder() { UseNoLock = useNoLock, RespectColumnSyntax = false }; var actualSql = qBuilder.From("User", useNoLock: useNoLock).Select("id", "name").Sql(); Assert.AreEqual(expected, actualSql); }
protected override IDb MakeDb() { var connectionString = "host=192.168.170.21;port=7432;user id=postgres;password=Test;Application Name=MoltoTests;database=Test"; IDbConnectionProvider dbConnectionProvider = new InMemoryDbConnectionProvider(); dbConnectionProvider.AddConnectionFactory("default", new PostgreSqlConnectionMaker(connectionString)); IDbValueConverter dbValueConverter = new PostgreSqlDbValueConverter(); IEntityDatabaseMapProvider entityDatabaseMapProvider = new EntityDatabaseMapProvider(new DirectPropertyEntityMapper()); IDataReaderToPoco dataReaderToPoco = new DataReaderToPoco(entityDatabaseMapProvider); entityDatabaseMapProvider.AddMap <Test>(); ISqlQueryCutter sqlQueryCutter = new SqlQueryCutter(); ISqlQueryBuilder sqlQueryBuilder = new PostgreSqlQueryBuilder(entityDatabaseMapProvider, sqlQueryCutter); return(new Db(dbConnectionProvider, dbValueConverter, dataReaderToPoco, sqlQueryBuilder)); }
public void ShouldReturnPagination_When_FilterIsProvided() { IQueryBuilder qBuilder = new PostgreSqlQueryBuilder() { RespectColumnSyntax = false }; var expected = "SELECT id,name FROM [User] WHERE Id=1 ORDER BY name ASC OFFSET (0) LIMIT 10"; var pagination = new PagedFilterBase() { Page = 1, PageSize = 10 }; var actualSql = qBuilder.Select("Id,Name").From("User").Where("Id=1").OrderBy(new OrderBy(true, "Name")).Paginate(pagination).Sql(); Assert.AreEqual(expected, actualSql); }