{"action":"created","issue":{"url":"https://api.github.com/repos/Dania02525/apartmentex/issues/27","repository_url":"https://api.github.com/repos/Dania02525/apartmentex","labels_url":"https://api.github.com/repos/Dania02525/apartmentex/issues/27/labels{/name}","comments_url":"https://api.github.com/repos/Dania02525/apartmentex/issues/27/comments","events_url":"https://api.github.com/repos/Dania02525/apartmentex/issues/27/events","html_url":"https://github.com/Dania02525/apartmentex/issues/27","id":184674657,"number":27,"title":"Prefix in `Apartmentex.drop_tenant` not being escaped properly?","user":{"login":"brandonparsons","id":1277162,"avatar_url":"https://avatars.githubusercontent.com/u/1277162?v=3","gravatar_id":"","url":"https://api.github.com/users/brandonparsons","html_url":"https://github.com/brandonparsons","followers_url":"https://api.github.com/users/brandonparsons/followers","following_url":"https://api.github.com/users/brandonparsons/following{/other_user}","gists_url":"https://api.github.com/users/brandonparsons/gists{/gist_id}","starred_url":"https://api.github.com/users/brandonparsons/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brandonparsons/subscriptions","organizations_url":"https://api.github.com/users/brandonparsons/orgs","repos_url":"https://api.github.com/users/brandonparsons/repos","events_url":"https://api.github.com/users/brandonparsons/events{/privacy}","received_events_url":"https://api.github.com/users/brandonparsons/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-10-23T06:37:11Z","updated_at":"2016-10-23T19:29:05Z","closed_at":"2016-10-23T19:29:05Z","body":"I'm trying to get `apartmentex` working for me. I'm assuming I'm not doing anything too crazy :)\r\n\r\nI'm using \"slugs\" as the tenant identifier on my Postgres schemas (I'm not using integer IDs, so would end up using a UUID, or a slug).  So for example, my database schemas look like `tenant_a-test-person`.\r\n\r\nAdding a tenant is working just fine. For example:\r\n\r\n```elixir\r\nApartmentex.new_tenant(Repo, client.slug)\r\n# --> Apartmentex.new_tenant(Repo, \"a-test-person\")\r\n```\r\n\r\nHowever, when I go to drop the schema, I'm getting errors due to the presence of `-` in the schema name.  For example:\r\n\r\n```elixir\r\nApartmentex.drop_tenant(Repo, client.slug)\r\n# --> Apartmentex.drop_tenant(Repo, \"a-test-person\")\r\n```\r\n\r\nThis ends up calling `DROP SCHEMA tenant_test-person CASCADE []` in the DB, and throws an error, as per below:\r\n\r\n```\r\n[debug] QUERY ERROR db=0.5ms\r\nDROP SCHEMA tenant_test-person CASCADE []\r\n[debug] QUERY OK db=0.2ms\r\nrollback []\r\n{:error, :drop_schema,\r\n %Postgrex.Error{connection_id: 70573, message: nil,\r\n  postgres: %{code: :syntax_error, file: \"scan.l\", line: \"1053\",\r\n    message: \"syntax error at or near \\\"-\\\"\", pg_code: \"42601\", position: \"24\",\r\n    routine: \"scanner_yyerror\", severity: \"ERROR\"}}, %{}}\r\n```\r\n\r\nI think all that needs to happen here is surround the schema name in quotes, e.g. `DROP SCHEMA \"tenant_test-person\" CASCADE []` - at least it worked for me testing in a PG shell.\r\n\r\nIs there a way to accomplish this with the library as-is?  I don't think using UUIDs (instead of a slug) would make any difference here, as they also include `-` characters.\r\n\r\nThanks for your help and putting this library together!\r\n"},"comment":{"url":"https://api.github.com/repos/Dania02525/apartmentex/issues/comments/255608704","html_url":"https://github.com/Dania02525/apartmentex/issues/27#issuecomment-255608704","issue_url":"https://api.github.com/repos/Dania02525/apartmentex/issues/27","id":255608704,"user":{"login":"brandonparsons","id":1277162,"avatar_url":"https://avatars.githubusercontent.com/u/1277162?v=3","gravatar_id":"","url":"https://api.github.com/users/brandonparsons","html_url":"https://github.com/brandonparsons","followers_url":"https://api.github.com/users/brandonparsons/followers","following_url":"https://api.github.com/users/brandonparsons/following{/other_user}","gists_url":"https://api.github.com/users/brandonparsons/gists{/gist_id}","starred_url":"https://api.github.com/users/brandonparsons/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brandonparsons/subscriptions","organizations_url":"https://api.github.com/users/brandonparsons/orgs","repos_url":"https://api.github.com/users/brandonparsons/repos","events_url":"https://api.github.com/users/brandonparsons/events{/privacy}","received_events_url":"https://api.github.com/users/brandonparsons/received_events","type":"User","site_admin":false},"created_at":"2016-10-23T19:29:05Z","updated_at":"2016-10-23T19:29:05Z","body":"@Dania02525 Whoo hoo! Yep it works. I obviously didn't know you guys were already all over this :)\r\n\r\nAgain, thanks for putting this library together. I'm just getting into Elixir/Phoenix, and wondering about converting a reasonably young Rails app over. If this library didn't exist, it wouldn't even be an option for me :) Will see if I can get up to speed fast enough!"}}
{"actor":{"display_login":"brandonparsons"}}