Sorry I've been pretty disconnected from this thread. 

The TL;DR version of the current situation is as follows: in Oracle, if a 
user has read access to tables/views not owned by him, those are not listed 
by the inspection mechanism inspectdb uses, so no model is generated for 
them. They can be inspected if their name is explicitly given though. My PR 
just offered a way of manually choosing what tables/views should be 
introspected and have code generated for them.

The solution proposed by the user Jani Tiainen in extending the 
functionality of my PR so that you can use wildcards to easily match more 
than one table/view.

If no more complexity is to be added, then the solution would be fixing the 
SQL I mentioned before [1] so that it correctly reports tables the user can 
read... and also removes support to introspect views to properly match the 
expected functionality of inspectdb (that in theory should not introspect 
views). I think the key would be using the ALL_TABLES view in Oracle 
instead of the USER_TABLES view, as it's suggested here [2]. This solution 
is the one that more closely matches your desires, Tim.



[1] 
: 
https://github.com/django/django/blob/53ccffdb8c8e47a4d4304df453d8c79a9be295ab/django/db/backends/oracle/introspection.py#L54
[2] : http://stackoverflow.com/a/205746/276451

El jueves, 19 de noviembre de 2015, 2:30:24 (UTC+1), Tim Graham escribió:
>
> One correction, inspectdb doesn't currently create models for views, but 
> this isn't the first time that code caused confusion, see 
> https://code.djangoproject.com/ticket/25038.
>
> I agree that fixing the inspect SQL would be the ideal solution. José, I 
> didn't follow the conversation closely enough to tell if you presented a 
> reason this infeasible for some reason? I'd rather not add more complexity 
> (arguments to inspectdb) where an easy solution already exists (removing 
> unwanted models from the generated output). 
>
> On Wednesday, November 11, 2015 at 7:40:49 AM UTC-5, Jani Tiainen wrote:
>>
>> Hi,
>>
>> I guess it's just about crafting proper SQL for Oracle to do proper 
>> introspection and do a PR to be inline with other backends what comes to 
>> table/view discovery.
>>
>> On 11.11.2015 14:14, José Tomás Tocino wrote:
>>
>> So... is this going anywhere?
>>
>> El lunes, 9 de noviembre de 2015, 17:55:36 (UTC+1), José Tomás Tocino 
>> escribió: 
>>>
>>> Well maybe extending queries to do that. Wonder is there similiar issues 
>>>> with postgresql?
>>>>
>>>
>>> Nope, I've just tried granting SELECT access to a user and he can 
>>> inspect the tables properly (in postgresql):
>>>
>>> postgres=# CREATE DATABASE permissions;
>>> CREATE DATABASE
>>> postgres=# \c permissions;
>>> You are now connected to database "permissions" as user "postgres".
>>> permissions=# create table foo (id int, name varchar(255));
>>> CREATE TABLE
>>> permissions=# GRANT CONNECT ON DATABASE permissions to tester;
>>> GRANT
>>> permissions=# GRANT USAGE ON SCHEMA public TO tester;
>>> GRANT
>>> permissions=# GRANT SELECT ON foo TO tester;
>>> GRANT
>>> permissions=# \q
>>> (ENV)vagrant@vagrant-ubuntu-trusty-64:~$ ./manage.py inspectdb
>>> # This is an auto-generated Django model module.
>>> # You'll have to do the following manually to clean this up:
>>> #   * Rearrange models' order
>>> #   * Make sure each model has one field with primary_key=True
>>> #   * Remove `managed = False` lines if you wish to allow Django to 
>>> create, modify, and delete the table
>>> # Feel free to rename the models, but don't rename db_table values or 
>>> field names.
>>> #
>>> # Also note: You'll have to insert the output of 'django-admin sqlcustom 
>>> [app_label]'
>>> # into your database.
>>> from __future__ import unicode_literals
>>>
>>> from django.db import models
>>>
>>>
>>> class Foo(models.Model):
>>>     id = models.IntegerField(blank=True, null=True)
>>>     name = models.CharField(max_length=255, blank=True, null=True)
>>>
>>>     class Meta:
>>>         managed = False
>>>         db_table = 'foo'
>>>
>>>
>>> So there's that
>>>  
>>>
>>>>
>>>> -- 
>>>> José Tomás Tocino García
>>>> http://www.josetomastocino.com
>>>> -- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "Django developers (Contributions to Django itself)" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>> an email to django-develop...@googlegroups.com.
>>>> To post to this group, send email to django-d...@googlegroups.com.
>>>> Visit this group at http://groups.google.com/group/django-developers.
>>>> To view this discussion on the web visit 
>>>> <https://groups.google.com/d/msgid/django-developers/CAAOwDo7J33ScxGvQ3UZe2HLMLbc1Eim1TPGwqFDap6Xdp%2BJkFw%40mail.gmail.com>
>>>> https://groups.google.com/d/
>>>> msgid/django-developers/CAAOwDo7J33ScxGvQ3UZe2HLMLbc1Eim1TPGwqFDap6Xdp%2BJkFw%
>>>> 40mail.gmail.com.
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>>
>>>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django developers (Contributions to Django itself)" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-develop...@googlegroups.com.
>> To post to this group, send email to django-d...@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-developers.
>> To view this discussion on the web visit 
>> <https://groups.google.com/d/msgid/django-developers/9acc3506-6585-4dd6-9463-0d431707e441%40googlegroups.com?utm_medium=email&utm_source=footer>
>> https://groups.google.com/d/msgid/django-developers/9acc3506-6585-4dd6-9463-0d431707e441%40googlegroups.com
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/277fcaec-e744-4650-8702-73b200a69aa3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to