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

Fix select from top missing alias bug #65

Merged
merged 2 commits into from
Jul 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/api/classes/common-table-expression.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Added in v1.0.0
with_: <Selection2 extends string, Alias2 extends string>(
alias: Alias2,
select: (acc: {
[K in Aliases]: Table<FilterStarting<Scope, K>, K>;
[K in Aliases]: Table<never, FilterStarting<Scope, K>, K>;
}) => SelectStatement<any, Selection2>
) =>
CommonTableExpressionFactory<
Expand All @@ -66,7 +66,7 @@ withR: <Selection2 extends string, Alias2 extends string>(
alias: Alias2,
columns: readonly Selection2[],
select: (acc: {
[K in Aliases]: Table<FilterStarting<Scope, K>, K>;
[K in Aliases]: Table<never, FilterStarting<Scope, K>, K>;
}) => SelectStatement<any, any>
) =>
CommonTableExpressionFactory<
Expand Down
6 changes: 4 additions & 2 deletions docs/api/classes/compound.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,13 @@ Added in v0.0.0
```ts
joinTable: <
Alias1 extends string,
Scope2 extends string,
Selection2 extends string,
Alias2 extends string
>(
thisCompoundAlias: Alias1,
operator: string,
table: Table<Selection2, Alias2>
table: Table<Scope2, Selection2, Alias2>
) =>
JoinedFactory<
Selection,
Expand All @@ -137,11 +138,12 @@ Added in v0.0.0
```ts
commaJoinTable: <
Alias1 extends string,
Scope2 extends string,
Selection2 extends string,
Alias2 extends string
>(
thisSelectAlias: Alias1,
table: Table<Selection2, Alias2>
table: Table<Scope2, Selection2, Alias2>
) =>
Joined<
Selection,
Expand Down
16 changes: 12 additions & 4 deletions docs/api/classes/joined.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,12 @@ Added in v0.0.0
**Signature**

```ts
commaJoinTable: <Selection2 extends string, Alias2 extends string>(
table: Table<Selection2, Alias2>
commaJoinTable: <
Scope2 extends string,
Selection2 extends string,
Alias2 extends string
>(
table: Table<Scope2, Selection2, Alias2>
) =>
Joined<
Selection,
Expand All @@ -117,9 +121,13 @@ Added in v0.0.0
**Signature**

```ts
joinTable: <Selection2 extends string, Alias2 extends string>(
joinTable: <
Scope2 extends string,
Selection2 extends string,
Alias2 extends string
>(
operator: string,
table: Table<Selection2, Alias2>
table: Table<Scope2, Selection2, Alias2>
) =>
JoinedFactory<
Selection,
Expand Down
6 changes: 4 additions & 2 deletions docs/api/classes/select-statement.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,12 @@ Added in v0.0.0
```ts
commaJoinTable: <
Alias1 extends string,
Scope2 extends string,
Selection2 extends string,
Alias2 extends string
>(
thisQueryAlias: Alias1,
table: Table<Selection2, Alias2>
table: Table<Scope2, Selection2, Alias2>
) =>
Joined<
Selection,
Expand All @@ -250,12 +251,13 @@ Added in v0.0.0
```ts
joinTable: <
Alias1 extends string,
Scope2 extends string,
Selection2 extends string,
Alias2 extends string
>(
thisQueryAlias: Alias1,
operator: string,
table: Table<Selection2, Alias2>
table: Table<Scope2, Selection2, Alias2>
) =>
JoinedFactory<
Selection,
Expand Down
6 changes: 4 additions & 2 deletions docs/api/classes/stringified-select-statement.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,12 @@ Added in v0.0.3
```ts
commaJoinTable: <
Alias1 extends string,
Scope2 extends string,
Selection2 extends string,
Alias2 extends string
>(
thisQueryAlias: Alias1,
table: Table<Selection2, Alias2>
table: Table<Scope2, Selection2, Alias2>
) =>
Joined<
Selection,
Expand All @@ -103,12 +104,13 @@ Added in v0.0.3
```ts
joinTable: <
Alias1 extends string,
Scope2 extends string,
Selection2 extends string,
Alias2 extends string
>(
thisQueryAlias: Alias1,
operator: string,
table: Table<Selection2, Alias2>
table: Table<Scope2, Selection2, Alias2>
) =>
JoinedFactory<
Selection,
Expand Down
20 changes: 14 additions & 6 deletions docs/api/classes/table.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ This class is not meant to be used directly, but rather through the `table` func
**Signature**

```ts
export declare class Table<Selection, Alias> {
export declare class Table<Scope, Selection, Alias> {
private constructor(
/* @internal */
public __props: {
Expand All @@ -57,7 +57,7 @@ Added in v0.0.0

```ts
clickhouse: {
final: () => Table<Selection, Alias>;
final: () => Table<Scope, Selection, Alias>;
}
```

Expand Down Expand Up @@ -103,8 +103,12 @@ Added in v0.0.0
**Signature**

```ts
commaJoinTable: <Selection2 extends string, Alias2 extends string>(
table: Table<Selection2, Alias2>
commaJoinTable: <
Scope2 extends string,
Selection2 extends string,
Alias2 extends string
>(
table: Table<Scope2, Selection2, Alias2>
) =>
Joined<
Selection,
Expand All @@ -124,9 +128,13 @@ Added in v0.0.0
**Signature**

```ts
joinTable: <Selection2 extends string, Alias2 extends string>(
joinTable: <
Scope2 extends string,
Selection2 extends string,
Alias2 extends string
>(
operator: string,
table: Table<Selection2, Alias2>
table: Table<Scope2, Selection2, Alias2>
) =>
JoinedFactory<
Selection,
Expand Down
7 changes: 4 additions & 3 deletions docs/api/index.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,11 @@ export declare const select: <
f:
| readonly SubSelection[]
| ((
f: Record<FromSelection, SafeString> & NoSelectFieldsCompileError
f: Record<FromSelection | FromScope, SafeString> &
NoSelectFieldsCompileError
) => Record<NewSelection, SafeString>),
from: TableOrSubquery<FromAlias, FromScope, FromSelection, FromAmbigous>
) => SelectStatement<FromSelection | FromScope, NewSelection | SubSelection>;
) => SelectStatement<FromSelection, NewSelection | SubSelection>;
```

Added in v1.0.0
Expand Down Expand Up @@ -259,7 +260,7 @@ export declare const table: <Selection extends string, Alias extends string>(
columns: readonly Selection[],
alias: Alias,
name?: string
) => Table<Selection, Alias>;
) => Table<`${Alias}.${Selection}`, Selection, Alias>;
```

**Example**
Expand Down
4 changes: 2 additions & 2 deletions src/classes/common-table-expression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class CommonTableExpressionFactory<
public with_ = <Selection2 extends string, Alias2 extends string>(
alias: Alias2,
select: (acc: {
[K in Aliases]: Table<FilterStarting<Scope, K>, K>;
[K in Aliases]: Table<never, FilterStarting<Scope, K>, K>;
}) => SelectStatement<any, Selection2>
): CommonTableExpressionFactory<
`${Alias2}.${Selection2}` | Scope,
Expand All @@ -86,7 +86,7 @@ export class CommonTableExpressionFactory<
alias: Alias2,
columns: ReadonlyArray<Selection2>,
select: (acc: {
[K in Aliases]: Table<FilterStarting<Scope, K>, K>;
[K in Aliases]: Table<never, FilterStarting<Scope, K>, K>;
}) => SelectStatement<any, any>
): CommonTableExpressionFactory<
`${Alias2}.${Selection2}` | Scope,
Expand Down
6 changes: 4 additions & 2 deletions src/classes/compound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,13 @@ export class Compound<Scope extends string, Selection extends string> {
*/
public joinTable = <
Alias1 extends string,
Scope2 extends string,
Selection2 extends string,
Alias2 extends string
>(
thisCompoundAlias: Alias1,
operator: string,
table: Table<Selection2, Alias2>
table: Table<Scope2, Selection2, Alias2>
): JoinedFactory<
Selection,
| Exclude<Selection, Selection2>
Expand Down Expand Up @@ -223,11 +224,12 @@ export class Compound<Scope extends string, Selection extends string> {
*/
public commaJoinTable = <
Alias1 extends string,
Scope2 extends string,
Selection2 extends string,
Alias2 extends string
>(
thisSelectAlias: Alias1,
table: Table<Selection2, Alias2>
table: Table<Scope2, Selection2, Alias2>
): Joined<
Selection,
| Exclude<Selection, Selection2>
Expand Down
16 changes: 12 additions & 4 deletions src/classes/joined.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,12 @@ export class Joined<
/**
* @since 0.0.0
*/
public commaJoinTable = <Selection2 extends string, Alias2 extends string>(
table: Table<Selection2, Alias2>
public commaJoinTable = <
Scope2 extends string,
Selection2 extends string,
Alias2 extends string
>(
table: Table<Scope2, Selection2, Alias2>
): Joined<
Selection,
| Scope
Expand All @@ -214,9 +218,13 @@ export class Joined<
/**
* @since 0.0.0
*/
public joinTable = <Selection2 extends string, Alias2 extends string>(
public joinTable = <
Scope2 extends string,
Selection2 extends string,
Alias2 extends string
>(
operator: string,
table: Table<Selection2, Alias2>
table: Table<Scope2, Selection2, Alias2>
): JoinedFactory<
Selection,
| Scope
Expand Down
6 changes: 4 additions & 2 deletions src/classes/select-statement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,12 @@ export class SelectStatement<Scope extends string, Selection extends string> {
*/
public commaJoinTable = <
Alias1 extends string,
Scope2 extends string,
Selection2 extends string,
Alias2 extends string
>(
thisQueryAlias: Alias1,
table: Table<Selection2, Alias2>
table: Table<Scope2, Selection2, Alias2>
): Joined<
Selection,
| Exclude<Selection, Selection2>
Expand All @@ -398,12 +399,13 @@ export class SelectStatement<Scope extends string, Selection extends string> {
*/
public joinTable = <
Alias1 extends string,
Scope2 extends string,
Selection2 extends string,
Alias2 extends string
>(
thisQueryAlias: Alias1,
operator: string,
table: Table<Selection2, Alias2>
table: Table<Scope2, Selection2, Alias2>
): JoinedFactory<
Selection,
| Exclude<Selection, Selection2>
Expand Down
6 changes: 4 additions & 2 deletions src/classes/stringified-select-statement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,12 @@ export class StringifiedSelectStatement<Selection extends string> {
*/
public commaJoinTable = <
Alias1 extends string,
Scope2 extends string,
Selection2 extends string,
Alias2 extends string
>(
thisQueryAlias: Alias1,
table: Table<Selection2, Alias2>
table: Table<Scope2, Selection2, Alias2>
): Joined<
Selection,
| Exclude<Selection, Selection2>
Expand All @@ -95,12 +96,13 @@ export class StringifiedSelectStatement<Selection extends string> {
*/
public joinTable = <
Alias1 extends string,
Scope2 extends string,
Selection2 extends string,
Alias2 extends string
>(
thisQueryAlias: Alias1,
operator: string,
table: Table<Selection2, Alias2>
table: Table<Scope2, Selection2, Alias2>
): JoinedFactory<
Selection,
| Exclude<Selection, Selection2>
Expand Down
Loading