dwyl / dwyl/learn-phoenix

How to run a "raw" SQL query using Ecto.Adapters.SQL.query

Open
#33 2 comments 0 reactions 1 assignee Claimed by @nelsonic View on GitHub
please-test
Dominant language
No language data
Stars
664
Forks
41
PR merge metrics
No merged PRs in 30d

Description

On page 119 of Programming Phoenix there's an _example_ for how to write a "direct" SQL query:
```
Ecto.Adapters.SQL.query(Rumbl.Repo, "SELECT, power($1, $2)", [2, 10])
```
This does not `SELECT` any data from the database it (_is meant to_) merely calculate `2^10` which `should return 1024` ... _instead_ we see:
![image](https://cloud.githubusercontent.com/assets/194400/23097412/fb52838e-f62a-11e6-9cbf-d2aaf372eb8f.png)

It's not a DB/connection error because other queries _work_! e.g:
![image](https://cloud.githubusercontent.com/assets/194400/23097416/1a975968-f62b-11e6-80e4-7d913f5fd811.png)

So... I'm left scratching my head as to _how_ to run an SQL query using Ecto ...
has anyone `else` attempted to do this?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.