GHC 2019-01-08

2 comments.

, https://git.io/fhGhU in coleifer/peewee
Window function in order_by causes syntax error
===============================================

Consider the following simple example:

```py
import logging
import peewee

db = peewee.SqliteDatabase("/tmp/test.db")


class Transaction(peewee.Model):
    user_id = peewee.IntegerField()

    class Meta:
	database = db


db.create_tables([Transaction], safe=True)

Transaction.insert_many(
    dict(user_id=user_id) for user_id in [1, 2, 1, 3, 4, 2, 3, 1]
).execute()

logger = logging.getLogger("peewee")
logger.addHandler(logging.StreamHandler())
logger.setLevel(logging.DEBUG)

# Using a pre-defined window object is okay.
win = peewee.Window(partition_by=[Transaction.user_id], order_by=[Transaction.id])
(
    Transaction.select()
    .order_by(peewee.fn.FIRST_VALUE(Transaction.id).over(win))
    .window(win)
    .execute()
)

# Defining a window directly in order_by is not okay.
(
    Transaction.select()
    .order_by(
	    peewee.fn.FIRST_VALUE(Transaction.id).over(
            partition_by=[Transaction.user_id], order_by=[Transaction.id]
        )
    )
    .execute()
)
```

Executing this produces:

```sql
('SELECT "t1"."id", "t1"."user_id" FROM "transaction" AS "t1" WINDOW w AS (PARTITION BY "t1"."user_id" ORDER BY "t1"."id") ORDER BY FIRST_VALUE("t1"."id") OVER w', [])
('SELECT "t1"."id", "t1"."user_id" FROM "transaction" AS "t1" ORDER BY FIRST_VALUE("t1"."id") OVER w AS (PARTITION BY "t1"."user_id" ORDER BY "t1"."id")', [])
Traceback (most recent call last):
  File "/path/to/venv/lib/python3.7/site-packages/peewee.py", line 2712, in execute_sql
    cursor.execute(sql, params or ())
sqlite3.OperationalError: near "AS": syntax error
```

The second query apparently shouldn't have `w AS` after `OVER`; removing that gives us a valid query. I'm not sure why a window alias is used in this case, and in a problematic manner; a window alias is not used if `FIRST_VALUE(...).over(...)` appears in `select()` instead.

, https://git.io/fhGQX in tbodt/ish
OpenSSH client already works fine (AFAICT). This issue is about ssh-agent, and the underlying issue is lack of support for Unix domain sockets. It seems Dropbear doesn't even have an agent.